|
Once you've fully developed and tested your application, it's time to create a package you can upload to the Android Market. Note: In order for the Android Market to accept your application, it must define an application level icon. Ensure a line like this exists in your AndroidManifest.xml: <application android:label="MyApplication" android:icon="@drawable/icon"> A future release will provide better support for setting this. Step 1: Change to Release ModeBy default, Debug mode uses the Mono shared runtime to make repeated deploying and testing quick, however you want your application to be fully self contained. Release mode turns off the shared runtime and turns on linking so that your application only ships the pieces of MonoDroid that it needs.
Next, check the Mono Android Options tab in your property pages to ensure that the shared runtime is turned off and linking (SDK Only or SDK and User Assemblies) is turned on.
Step 2: Test in Release ModeTurning on linking can sometime have unintended side effects, so you need to fully test your application in Release mode. For a discussion on linking see Linking. Step 3: Create a Market Private KeystoreYou only need to do this step once. You should always use the same key, so make sure you don't lose it. If you lose it, you will not be able to make updates to your application on the Market, you will have to remove your application and resubmit it as a new application. For more information see the Android Private Key Documentation. Basically, you need to find "keytool" in the Java SDK, and use this command: keytool -genkey -v -keystore <my-keystore-name>.keystore -alias <key-name> -keyalg RSA -keysize 2048 -validity 10000 Fill in The will produce a file containing you key called Step 4: Sign the PackageThere are two ways to sign the package, depending on how you want to manage the keystore. By default, Mono for Android builds will generate a debug keystore, which can't be used for Android Market deployment. If you prefer, you can elect to use a different keystore for all packaging operations. Permanently Use A Different KeystoreIf you would like to always use the keystore created in Step (3), you can alter your Project.csproj file to contain signing information: <PropertyGroup>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>public</AndroidSigningStorePass>
<AndroidSigningKeyAlias>public</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>public</AndroidSigningKeyPass>
</PropertyGroup>
Alter the AndroidSigningKeyStore, AndroidSigningStorePass, AndroidSigningKeyAlias, and AndroidSigningKeyPass element values as appropriate for your deployment. For more information see the Signing section in the Build Process Article. If you just want to use a specific keystore for Release builds, and/or use a different keystore for Debug builds, you can use MSBuilds Condition attribute: <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>public</AndroidSigningStorePass>
<AndroidSigningKeyAlias>public</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>public</AndroidSigningKeyPass>
</PropertyGroup>
Manually Use a Different KeystoreManually using a different keystore currently requires:
Step A - Locating the Unsigned PackageMake sure you've build and deployed your final package (.apk) in Release mode (the package gets built when you deploy), then you can find the package in your \bin\Release folder.
Note that you do not want the "-Signed" one. This one is signed with a debug key for you to deploy to your device for testing. You want the unsigned one so you can sign it with your Marketplace key. Step B - Sign the PackageOnce you have your key created, you are ready to sign your package for the Marketplace. For more information see the Android Package Signing documentation. You need to find the "jarsigner" tool in the Java SDK, and use this command: jarsigner -verbose -keystore <my-keystore-name>.keystore <package .apk> <key-name> The package is signed in place, so it is the same package, not a new one. To ensure it is signed correctly, you can run: jarsigner -verify <package .apk> Step C - Aligning the PackageThe final step in preparing your package for the Marketplace is to align the package. This is a MANDATORY performance optimization to help Android load your application faster. For more information see Android's Aligning Documentation. If you do not do this, your application will fail in random ways. You need to find the "zipalign" tool in the Android SDK, and use this command: zipalign -v 4 <package .apk> <final package name>.apk Step 5 - Upload to Android MarketplaceYour application is now fully packaged and ready to be uploaded to the Android Marketplace! To get started, visit: http://market.android.com/publish |