Jump to content

How to Sign your Android App

0
  chco's Photo
Posted Dec 09 2010 03:32 PM

Android requires that all apps be digitally signed by the developer. The process for doing so is easy, but a little cryptic. The excerpt below from Building Android Apps with HTML, CSS, and Javascript will help guide you through the process.


  • Launch the Terminal application and navigate into the KiloGap (or whichever directory your application is stored in) directory:

    cd ~/Desktop/KiloGap

  • 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.

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

    Attached Image


  • 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. 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.

    The keytool command will generate a keystore file named myAndroidKey.keystore in the KiloGap directory

    Attached Image


    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.

  • 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.

  • 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. This .apk file is your completed app!


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

Attached Image


Building Android Apps with HTML, CSS, and Javascript

Learn more about this topic from Building Android Apps with HTML, CSS, and Javascript.

If you know HTML, CSS, and Javascript, you already have the tools you need to develop Android applications. This hands-on book shows you how to use these open source web standards to design and build apps that can be adapted for any Android device -- without having to use Java. You'll learn how to create an Android-friendly web app on the platform of your choice, and then convert it to a native Android app with the free PhoneGap framework. Discover why device-agnostic mobile apps are the wave of the future, and start building apps that offer greater flexibility and a broader reach.

See what you'll learn


Tags:
0 Subscribe


1 Reply

0
  Arise Peter's Photo
Posted Jan 14 2013 12:13 AM

It is not difficult to sign and publish your app as mentioned above. you can directly export it and eclipse will automatically sign it. You can see the below article. It shows how to sign and publish an app in an easiest way using sreen shots and graphics.
http://android-helpe...20in%20Andrioid