Sep 242011
 

This tutorial explains how to generate a key (keystore) to sign your Android application.

I know a lot of you are probably surprised I’m writing about Android, however lately I’ve seen a number of people requesting information and I really wanted to make it simple.

I will state right now that not being very experienced with Android, (I have no device currently I can build for,) I do not know whether it is correct to call this a “key” or a “keystore” – so I’m sticking with “key” for now ;)

*NOTE: This is a key for building apps for the Android Market. For testing, use the debug key you already have.

**This is written for Mac users only.

Step 1 ) Open the terminal.

Step 2 ) Type in keytool -genkey -v -keystore yourappname.keystore -alias appnamealias -keyalg RSA -keysize 2048 -validity 10000

Changing the parts I have bolded into your own information.

Then hit enter.

Step 3 ) You will be asked for a password; don’t use anything you will forget and if you need to, write it down. It you lose the password you wont be able to update your application in the future.

Step 4 ) You will asked to re-enter you password, do so, then hit enter again.

Step 5 ) You’ll be asked for your first and last names, key those in, hit enter again.

Step 6 ) You’ll be asked for the name of your “organizational unit” – I would use Techority for mine – you would likely use your studio name or, if you don’t have any alternatives, your own full name. (I guess this would really be more suited to entering a division within a company, like “marketing” or “sales”, but I wouldn’t remember that.) Enter again.

Step 6 ) You’re asked for the name your organization, I would again use Techority and you would do as you’ve done above. (Studio name or full name.)

Step 7 ) You’ll be asked for your “city of locality”, I live in the city of Sydney currently, so that was my answer.

Step 8 ) You’ll be asked for your “state or province”, I’m in New South Wales, so I typed that in.

Step 9 ) More location questions, you will need to key in the two letter code for your country. The United States is of course “US”, Australia for me was “AU”.

Step 10 ) Finally, you will be asked to confirm all is correct and then enter your password once more, which will be the same as the one you entered and reentered in steps 3 and 4.

Step 11 ) The .keystore file has been created! You can find it by clicking on the magnifying glass in the top right and doing a quick search for .keystore – move it to a safe folder you have created and be sure to back that up immediately.

And that’s it!

You can now build your Android app using your newly generated key :)

I hope this is of use to you all, I know many of us do not develop for Android (yet?) but it’s information I felt was important to get out there.

I’d like to say thanks to Joe of Fire Maple Games as he was the one to originally teach me how to do this.

Peach Pellen :)

Like this post? Subscribe to the monthly newsletter!

 

  29 Responses to “How To Generate A Key For Your Android App”

  1. Check the version number you set in build.settings – there are threads about this on the forum that will be more useful than me on this as I don’t do much with Android at all ;)

    Believe is easy fix, though.

  2. Hey, I got it!

    I generated my key alright, but when my apk was ready and I tried to upload it to android market, I got this error from their site:

    Google Play requires versionCode to be set to a positive 32-bit integer in AndroidManifest.xml

    What should I change to meet their demands??
    Thanks a lot Peach..

  3. Open a new terminal window – not the corona one.

    You can do that by typing “terminal” in the spotlight bar top right :)

  4. Hi Peach,

    Another dumb question for you: is this the same terminal from corona? Cause I’m trying with it, and when I hit enter with this
    “keytool -genkey -v -keystore lovefortunefree.keystore -alias lovefortune -keyalg RSA -keysize 2048 -validity 10000″,
    I get nothing..it just goes down one line, blank.
    What can I be doing wrong?
    Tks

  5. Great, happy to help! :)

  6. Peach, thank for answer, it is new information for me .-)

    It heleped!

  7. Thank you for article, it helped me. Can I have stupid question?

    What mean by “alias”, can you give real example? Is it another name for application (like “nick”)? I don’t really understand this :-)

    And another more stupid question – for each one application for Corona apk I need new key or I can use the same?

    Thank you!

    • Hey there, not stupid at all :)

      Alias is yes, like another name – although often you will just use the full name. If you wanted to abbreviate it, say from “Bob’s Fantastic Adventure” to “bobadventure”, etc, that’s an alias in this case.

      Is this clear enough? (I know it can be hard to get your head around at first.)

      For publishing to the Market you need a key for each – with all Android apps including those made with Corona, yes :)

  8. Thanks Rodrigo – that is very sweet of you :)

    Don’t worry, haha, if you were my neighbor I would not run away ^-^; One day you’ll meet me and see :)

  9. Don`t feel sorry!

    Did not you know that just your presence in this world is a enormous help for me Mrs?

    Peace. :)

    PS: I wish I would be your neighbor! (and you run away from) LOL

  10. Glad you got it – sorry I wasn’t able to assist :)

  11. Thank you Mrs.

    Wasn`t exactly this but I think I got it now.

    Nevermind. ;)

  12. You choose the same keystore you made when you first built it to build updates; is that what you are asking? (Sorry, I’m not totally sure.)

  13. Peach,

    How can I sign an .apk after I edit its manifest? Because if I build again with Corona it pass over the .apk edited by me and so I come back to the begin. :\

    Thanks! :)

  14. No worries my friend, I’ll always answer you :)

  15. Yes, I got it lady! :)

    I really appreciate your time answering me! ;)

    See you later,

    Peace!
    Rodrigo.

  16. Hey Rodrigo,

    This is fine – don’t worry – ask me whatever you like and I will help if I can. (I can’t always help with Android stuff but I do my best.)

    For that identifier, it is like in iOS when you do com.yourname.appname :)

    I think it forces you to enter one for testing and not just the store, though I can’t recall – if it does you could just do com.yourname.testapp or the like :)

    Get it? :)

  17. Hello my best friend!

    Look, mind you of help me one more time? :)

    As you know, am starting to Android Development only now and so am a nO.ob about it all! :\

    So, as I have MANY questions, and I know you`re BUSY, I`ll ask just one:

    So, my question is: Do I need to write something inside that text box showed when building on Corona Simulator for Android that says: “Package: (a unique java-style package identifier for your app).

    So do I need to do that always? When build for debug purpose and when building for store? :\

    Sorry lady, but I do not know really.

    Thank YOU! ;)
    Rodrigo.

  18. Sorry i have another question, you know if the keytool embedd the password on the key ?
    Thanks !

  19. Hey,

    Yes, it creates the key and you choose your password. Yes, a strong password is important in all situations, I would suggest using at least a combination of letters and numbers – but throwing in some capital letters or punctuation wouldn’t hurt either.

    Peach :)

  20. Thanks Peach !
    Just to understand, the keytool create the key and you a password ?
    So what secure your key is the strongness of your password ?

  21. Hey,

    Ah, I don’t know what a PUBLIC key is – I don’t do Android, really. (Yet.)

    The steps above work for an app for the Google MarketPlace – you only use the debug key for testing on your own device.

    For Facebook, I don’t know how it works with Android either as like I said, I don’t yet build for Android. (I’ve done it like twice, a long time ago now.)

    Sorry! Above steps WILL work for Market Place app, though :)

    Peach

  22. HI Peach Pellen

    I have this dumb question Android Market requires app sign ok ?

    But i need to use my PUBLIC KEY of developer console ?

    Facebook need Android Key Hash, i need to use my PUBLIC KEY here too ?

    Many thanks in advance !

  23. No worries, glad I could help :)

  24. YAYYYYYYY
    Thanks! I needed this.

  25. Hi Peach.

    Just wanted to say that this works on Windows, as well, as long as you have the JAVA_HOME environment variable properly set or the path to your Java installation in your PATH env variable, will also work on Linux too. Cheers

  26. That’s quite a little collection you’ve got there!

    Glad you liked it :)

    Peach

  27. Your timing is perfect. I have 3 android devices and I was thinking about testing for them. Droid x, samsung galaxy s and a nook with android.

    I’ll need to upgrade my license but at least I know how to do it now. Yee haw!

    Ng

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.