On Jan 8, 2013, at 9:37 AM, John Murray <j...@murray.gb.com> wrote:
> Any idea how I can get an up to date debug.keystore file

You are now entering a maze of twisty passages, all alike. Your sanity is 
likely to disappear.

First of all, where'd debug.keystore come from? Mono for Android auto-generates 
it during the build process if it doesn't already exist (because all apps need 
to be signed to get them onto the device). If you need a new one, delete it and 
a new one will be auto generated:

        OSX: $HOME/.local/share/Xamarin/Mono for Android/debug.keystore
        Windows: %LOCALAPPDATA%\Xamarin\Mono for Android\debug.keystore

HOWEVER, that's only part of the problem, and this is where things get crazy.

Since debug.keystore is automatically created, it will DIFFER between every 
machine that Mono for Android is installed on. This is fine outside of Google 
Maps, but when you need to use Google Maps (and it's API key) and you're on a 
team this will result in pain, suffering, and misery (because only one person 
will be able to build the app!).

So when it comes to Google Maps, you DO NOT want to use the default 
debug.keystore file!

Instead, create a new one:

        
http://docs.xamarin.com/Android/Guides/Deployment%2C_Testing%2C_and_Metrics/publishing_an_application/Part_1_-_Preparing_an_Application_for_Release#Creating_a_Private_Keystore

Add it to your source repo, and update your project so that the included 
keystore is used instead of the default keystore:

        
http://docs.xamarin.com/Android/Guides/Advanced_Topics/Build_Process#Signing
        
http://docs.xamarin.com/Android/Guides/Deployment%2C_Testing%2C_and_Metrics/publishing_an_application/Part_1_-_Preparing_an_Application_for_Release#Permanently_Use_A_Different_Keystore

This allows things to be "sane" in a team environment, but the security 
implications are terrible: you have a (private!) keystore in a "public" 
(presumably internal) source control repo, and the password + alias + etc. are 
stored in plain text in your .csproj.

This is NOT SECURE. It WORKS, but it's not secure. (Related note: this might 
not be "that bad"; if someone can access the in-repo keystore, they can also 
access all the source included in that repo, which is presumably something you 
don't want easily accessible either...)

Bear that in mind. ;-)

For Release apps, you'll want (need) to use a DIFFERENT keystore file, 
protected with actual security precautions (e.g. not stored on a network 
accessible computer), and then MANUALLY sign your Release app with this Release 
keystore:

        
http://docs.xamarin.com/Android/Guides/Deployment%2C_Testing%2C_and_Metrics/publishing_an_application/Part_1_-_Preparing_an_Application_for_Release#Signing_the_APK_in_Visual_Studio_(Mono_for_Android_4.2.6_or_higher)

Of course, since your Release app is using a different keystore file, it'll 
also have a different Google Maps API key (argh!). You'll probably thus want to 
store the API key as a String resource, and have per-build string resources 
(one for Debug builds, one for Release builds):

        
http://docs.xamarin.com/Android/Guides/Deployment%2C_Testing%2C_and_Metrics/publishing_an_application/Part_1_-_Preparing_an_Application_for_Release#Storing_Google_Maps_API_Keys

Related/different idea to the above: to your Project, add two files: 
Resources\Values\ApiKey-Release.xml and Resources\Values\ApiKey-Debug.xml:

        <resources>
                <string name="google_maps_api_key">...</string>
        </resources>

Update "..." with the appropriate value (Debug key in the -Debug file, Release 
key in the -Release file). Add one to your .csproj via the IDE, close the 
project, then manually edit the .csproj to replace the ApiKey-*.xml entry with:

        <AndroidResource Include="Resources\Values\ApiKey-$(Configuration).xml" 
/>

This will make the API key a per-configuration value: build Debug, and you'll 
use the ApiKey-Debug.xml file (and thus Debug key), build Release and you'll 
use the ApiKey-Release.xml file (and thus Release key). This has the added 
benefit that your layout XML can "just" use @string/google_maps_api_key, 
removing the need to have per-profile Layout files.

 - Jon

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to