MOBILE

Building Android Apps : Submitting Your App to the Android Market - Preparing a Release Version of Your App

1/17/2011 5:41:49 PM

You need to do a few things to get the app ready for distribution:

  • Remove any debugging or logging code

  • Version the app

  • Compile the app

  • Sign the compiled app with a private key

1. Removing Debug Code

There’s no reason to have debugging or logging code slowing down your app while it’s running on a user’s phone. If you have added any such code to your HTML, CSS, or JavaScript files, now’s the time to take it out.

You should also open up the AndroidManifest.xml file in the KiloGap folder, search for “debuggable” and set it to false. When you’re done, it should look something like this:

...
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="false">
...


Note:

While you have the manifest file open, you might as well check to make sure android:icon and android:label are specified as shown in the previous listing. PhoneGap normally takes care of this for you, but I think it’s worth double checking, because you won’t be able to upload your app if these values are not set.


2. Versioning Your App

Near the top of your AndroidManifest.xml file, you should see values set for the version name and version code for your app:

...
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jonathanstark.kilo"
android:versionName="1.0.0"
android:versionCode="1">
...

Because this is probably your first app, these values are fine as is. Once you’ve published your app and later want to release an update, you’ll update these values appropriately. The Android system doesn’t check or enforce this version information, but it’s a critical piece of data for your long term app strategy.

The version name is the value that will be shown to the user. It’s a string, so you can put whatever you want here, but the common practice is to use a <major>.<minor>.<point> format (such as 1.0.0).

The version code is expected to be a positive integer value. It need not correspond to the version name in any way. In fact, it probably won’t—you should just increment it by 1 every time you release an update, regardless of whether the release is a major upgrade or a minor bug fix.

3. Signing Your App

Android requires that all apps be digitally signed by the developer. The process for doing so is easy, but a little cryptic:

  1. Launch the Terminal application and navigate into the KiloGap directory:

    cd ~/Desktop/KiloGap

  2. Compile the app in release mode:

    ant release

    You’ll see a page or so of output scroll by, ending with BUILD SUCCESSFUL. An unsigned binary named Kilo-unsigned.apk will now be sitting in the ~/Desktop/KiloGap/bin/ directory (Figure 1).

    Figure 1. The ant release command creates an unsigned binary named Kilo-unsigned.apk in the ~/Desktop/KiloGap/bin/ directory

  3. Create a private key:

    keytool -genkey -v -keystore keystore -alias alias -keyalg RSA -validity days

    This command is interactive and will ask you a bunch of questions. Mine looks like this:
    JSC-MBP:KiloGap jstark$ keytool -genkey -v -keystore myAndroidKey.keystore \
    -alias myAndroidKeyAlias -keyalg RSA -validity 10000
    Enter keystore password:
    Re-enter new password:
    What is your first and last name?
    [Unknown]: Jonathan Stark
    What is the name of your organizational unit?
    [Unknown]:
    What is the name of your organization?
    [Unknown]: Jonathan Stark Consulting
    What is the name of your City or Locality?
    [Unknown]: Providence
    What is the name of your State or Province?
    [Unknown]: RI
    What is the two-letter country code for this unit?
    [Unknown]: US
    Is CN=Jonathan Stark, OU=Unknown, O=Jonathan Stark Consulting, L=Providence,
    ST=RI, C=US correct?
    [no]: yes

    Generating 1,024 bit RSA key pair and self-signed certificate (SHA1withRSA) with
    a validity of 10,000 days for: CN=Jonathan Stark, OU=Unknown, O=Jonathan Stark
    Consulting, L=Providence, ST=RI, C=US
    Enter key password for <myAndroidKeyAlias>
    (RETURN if same as keystore password):
    [Storing myAndroidKey.keystore]

    When the process completes, you should see myAndroidKey.keystore created in the ~/Desktop/KiloGap directory (Figure 2). If you’d like to use this keystore for other apps in the future, you might want to move the keystore file to a more central location.
    Figure 2. The keytool command will generate a keystore file named myAndroidKey.keystore in the KiloGap directory


    Warning:

    Do not lose this password. If you forget your keystore password, you won’t be able to update your app once it’s published.


  4. Sign your app with the key you just created:

    jarsigner -verbose -keystore myAndroidKey.keystore 
    ./bin/Kilo-unsigned.apk myAndroidKeyAlias

    When you run this command, you’ll be asked for your keystore password.

  5. Align the .apk file:

    zipalign -v 4 ./bin/Kilo-unsigned.apk ./bin/Kilo.apk

    You’ll see a page or so of output scroll by, ending with “Verification successful.” A signed binary named Kilo.apk will now be sitting in the ~/Desktop/KiloGap/bin/ directory (Figure 3). This .apk file is your completed app!

    Figure 3. Once you run the jarsigner and zipalign commands, your final app will be generated in the ~/Desktop/KiloGap/bin/ directory

Other  
  •  Windows Phone 7 Development : Creating a Cloud Service to Access the Cloud Database (part 2) - Implementing a WCF Service to Access the SQL Azure Database
  •  Windows Phone 7 Development : Creating a Cloud Service to Access the Cloud Database (part 1) - Generating an Object Model to Access the Cloud Database
  •  Windows Phone 7 Development : Using Cloud Services As Data Stores - Creating a Cloud Database
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 5) - Implementing the View Controller Logic
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 4) - Hiding the Keyboard
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 3) - Creating Styled Buttons
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 2) - Adding Text Views
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 1) - Adding Text Fields
  •  Building Android Apps : Controlling the Phone with JavaScript (part 3) - Accelerometer
  •  Building Android Apps : Controlling the Phone with JavaScript (part 2) - Geolocation
  •  Building Android Apps : Controlling the Phone with JavaScript (part 1) - Beep, Vibrate, and Alert
  •  Building Your First Windows Phone 7 Application (part 5) - Styling Your Application
  •  Building Your First Windows Phone 7 Application (part 4) - Customizing Your First Windows Phone Application
  •  Building Your First Windows Phone 7 Application (part 3) - Writing Your First Windows Phone Code
  •  Building Your First Windows Phone 7 Application (part 2) - Using Your First Windows Phone Silverlight Controls
  •  Building Your First Windows Phone 7 Application (part 1) - Creating a Windows Phone Project
  •  Introducing Windows Phone 7 and the Windows Phone Platform
  •  Windows Phone Application Platform
  •  iPhone Application Development : Basic User Input and Output
  •  Mobile Phone Game Programming : A Quick J2ME Primer
  •  
    Most View
    Getting The Most From Passbook
    Visual Studio Team System 2008 : Command Line (part 1)
    Mini Products Reviews (Part 1)
    Buying Guide: Best Cases For Your New PC
    Phone On Your Wrist!
    Popular GPS Apps Shootout (Part 3)
    Preparing Your Windows 8 PC : Managing Your PC Power - Choosing a Power Management Plan, Changing Power Options
    Security Software : Bitdefender Antivirus Plus 2013
    Improve Your Mac (Part 4) - Tips for saving bandwidth
    Sony RX100 - Music To Your Ears!
    Top 10
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 4)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 3)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 2)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 1)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 3)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 2)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 1)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 1)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 3)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 2)