You need to do a few things to get the app ready for
1. Removing Debug Code
There’s no reason to have debugging or logging code slowing down your app while it’s
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:
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:
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
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:
Launch the Terminal application and
navigate into the KiloGap directory:
Compile the app in release mode:
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/
Create a private key:
keytool -genkey -v -keystore keystore -alias alias -keyalg RSA -validity daysThis 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 \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.
-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?
What is the name of your organization?
[Unknown]: Jonathan Stark Consulting
What is the name of your City or Locality?
What is the name of your State or Province?
What is the two-letter country code for this unit?
Is CN=Jonathan Stark, OU=Unknown, O=Jonathan Stark Consulting, L=Providence,
ST=RI, C=US correct?
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):
Figure 2. The keytool command will generate a keystore file named
myAndroidKey.keystore in the KiloGap directory
Do not lose this password. If you
forget your keystore password, you won’t be able to update your
app once it’s published.
Sign your app with the key you just
jarsigner -verbose -keystore myAndroidKey.keystore
When you run this command, you’ll be
asked for your keystore password.
Align the .apk
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
Figure 3. Once you run the jarsigner and zipalign commands, your
final app will be generated in the ~/Desktop/KiloGap/bin/