Sign Your Games APK

After you have successfully registered as an official Android developer it's time to prepare your application for publishing. In order to publish your application you have to sign the APK file. Before we do that we should make sure everything is in place. Here's a laundry list of things to do before signing the application:

■ Remove the android:debuggable attribute from the <application> tag in your manifest file.

■ In the <manifest> tag you'll find the android:versionCode and android:versionName attributes. If you have already published a previous version of your application, you have to increase the versionCode attribute and should also change the versionName. The versionCode attribute has to be an integer; the versionName can be anything you like.

■ If your build target is equal to or higher than SDK level 8 (Android 2.2), you should also make sure the <manifest> tag has the android:installLocation attribute set to preferExternal or auto. This will ensure that your application is stored on the external storage if possible and make your users happy.

■ Make sure you only specify the permissions your game really needs. Users don't like to install applications that seem to need unnecessary permissions. Check the <uses-permission> tags in your manifest file.

■ Double-check that you set the android:minSdkVersion and android:targetSdkVersion correctly. Your application will only be visible on the Android Market to phones that run a version of Android equal to or higher than the specified SDK version.

Double-check all of those items. Once you are done you can finally export a signed APK file ready to be uploaded to the market:

1. For this you have to right-click your project in the package explorer view and select Android Tools > Export Signed Application Package. You'll be greeted with the dialog shown in Figure 13-1.

Figure 13-1. The signed export dialog

2. Click the Next button to bring up the dialog in Figure 13-2.

Figure 13-2. Choosing or creating the keystore

3. A keystore is a file that is password-protected and stores keys you sign your APK files with. Since we haven't created one yet, we do so now in this dialog. Just provide the location of the keystore along with a password that you will use to secure it. If you have already created a keystore (for example, if you're publishing a second version of your application) you can check the "Use existing keystore" radio button and just provide the dialog with the location of the key store file. Click the Next button to bring up the dialog shown in Figure 13-3.

Figure 13-3. Creating the key for signing the APK

For a valid key you have to fill out the alias, password, and validity in years as well as a name in the First and Last Name text box. The rest is optional but I tend to fill that out as well. Another click on Next and we are shown the final dialog (Figure 13-4).

£ Export Android Applicatior^^^^^^^^^^^^^^^^^^^^^^^^^^H!

Destination and key/certificate checks

TT

1 II

Destination APK file C:\Users\mzechner\Desktop\chl2-droidinvaders.apk

; Browse...;

L

Certificate expires in 1000 years.

Certificate expires in 1000 years.

Figure 13-4. Specifying the destination file

5. And we are basically done. Just specify where the exported APK file should be stored and remember that path. We'll need it later when we want to upload that APK to the market.

When you want to publish a new version of a previously published application, you can just reuse the keystore/key you created the first time you went through that dialog. In the dialog in Figure 13-2, just select the keystore file you created previously and provide the password for the keystore. You'll then be shown the dialog in Figure 13-5.

Figure 13-5. Reusing a key

Just select the key you created previously, provide the password for it, and proceed as before. In both cases you get a signed APK file that is ready for upload to the Android Market.

NOTE Once you upload a signed APK you have to use the same key for signing any subsequent versions of the same application.

0 0

Post a comment