A Sling and a Stone
android

Signing an Android APK for Release to the Android Market on Mac OS X

| 5 Comments

Here is a list of what needs to happen in it’s simplest form:

  1. Make a private key
  2. Compile your app
  3. Sign your app
  4. Align your app
  5. Upload to the Android Market

1. Make a private key

There are a variety of ways to make a private key on Mac OS X, but for this tutorial I’m going to be using keytool.  Keytool is an executable that’s included with the Mac OS X Development Kit.  So if you’ve ever done anything with Cocoa for iOS or Mac OS, you’re good.  Otherwise, you may have to download the developer tools from Apple to be able to use keytool.

Basically, just type the command below in Terminal.  It will ask your for a password, so type it twice (and remember it).

keytool -genkey -v -keystore android-test.keystore

2. Compile your App

Open up your app in Eclipse.  Open your AndroidManifest.xml file.  Using the Android SDK (the Manifest tab), under Export, select Export an unsigned APK.

3. Sign your app

Now it’s time go back to Terminal.  You will now use Jarsigner to sign  your application.  Again, Jarsigner is part of the Apple Development Kit.  The command you need to use will look something like this:

jarsigner -verbose -keystore android-test.keystore "PATH_TO_YOUR_APP.apk" alias_name

4. Align your app

Zipalign is part of the Android SDK that you’ve already downloaded.  It’s located in where ever you’ve saved the Android SDK/tools/zipalign.  So something like what I have below in the next command you need to use:
/SDKs/android-sdk-mac_86/tools/zipalign -f -v 4  "/SDKs/android-sdk-mac_86/Versed.apk" "/Users/Cam/Versed.apk"
Note: You must have the absolute paths to both your APK file and the zipalign tool (In case you were wondering, I use the quotes because sometimes people put spaces in their file names and Terminal doesn’t like that .  This just ensures the file path is correct).
The 2nd to last command in that line specifies input file and the last command is the output file.  That’s really all you need to know.

5.Upload to the Android Market

Setup an account if you don’t have one already.
Scroll to the bottom of the page to this: “If you are a developer, learn about publishing your application here.”
Click on here.
Fill out all the requirements and Upload your app!
  • http://musicaenlineagratis.org Musica online

    I think this is among the most significant info for me. And i am glad reading your article. But wanna remark on some general things, The site style is ideal, the articles is really great : D. Good job, cheers

  • http://android.coolest.ws/2011/01/signing-an-android-apk-for-release-to-the-a-sling-and-a-stone/ Signing an Android APK for Release to the … – A Sling and a Stone

    [...] Signing an Android APK for Release to the … – A Sling and a Stone Related Posts:Signing an Android APK for Release to the Android Market on Mac OS XRhyme Deception [...]

  • Smetoxen

    This is just what I needed! However, the code to type in was cutting off on the page in Safari. So I opened the website in FireFox and I could see all the text to type into terminal.

  • http://www.gingerbeardman.com gingerbeardman

    Thanks for this. I had to add -validity and -alias arguments and associated values when generating my keystore.

  • fiffy

    For the Android Market you should create a certificate that last at least 50 years:
    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000