Signing Android Applications In 3 Easy Steps

95 replies [Last post]

Replies

clercky
User offline. Last seen 5 years 9 weeks ago. Offline
Joined: 4 Jun 2011

Hey Jordan, but i´ve the JDK and i´ve done all of the things in the thread here :(
Can someone help me via teamviewer ?

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

@clercky Email me and I'll try to help you with your problems. ninjapig123[at]gmail.com

Regards,
Jordan Schuetz
Ninja Pig Studios

carlos.varela.com
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 24 Aug 2010

For Mac Users:

Correct command at the terminal is:

sudo keytool -genkey -v -keystore yourkeystorename.keystore -alias youraliasname -keyalg RSA -validity 999999

regards,

Varela

hello12
User offline. Last seen 6 years 6 weeks ago. Offline
Joined: 4 Jul 2011

Hola,

I've done everything here, and I get the file to build alright. But when I put the file on my phone, I just keep getting a parsing error. What does this mean? I've been using the method of uploading the .apk file to Dropbox, then downloading to my phone from there.

Thanks,

Nick

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

If your device is not an ARM7 device, or it is below the 2.2 software update, then it will not work on your phone.

Regards,
Jordan Schuetz
Ninja Pig Studios

w2md
User offline. Last seen 4 years 4 weeks ago. Offline
Joined: 18 Oct 2010

Any idea about issuing updates to a currently selling app? I'm getting an error when I try and upload it to the market. It says that my manifest xml file is too big. I think I might need the original key that was produced, but I don't have that anymore. Any ideas?

Thanks,

Matt
W2MD

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

You will always need your original Keystore if you want to make an update on the Android market. If you lost it, that's a huge disappointment. Also what does your config.lua and build.settings file look like. Maybe you made an error?

Regards,
Jordan Schuetz
Ninja Pig Studios

w2md
User offline. Last seen 4 years 4 weeks ago. Offline
Joined: 18 Oct 2010

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- config.lua
 
application =
{
content =
        {
                width = 320,
                height = 480,
                scale = "zoomEven",
                audioPlayFrequency = 44100,
                imageSuffix =
                {
                        ["@2x"] = 2,
                }
        },      
}  --try scale as "letterbox" or "zoomStretch" or "zoomEven" as well

and here's the build.settings file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
settings = {
        orientation = {
 
                default = "portraitRight",
                supported = { "portraitLeft", "portraitRight" },
 
        },
                iphone =
        {
                plist =
                {
                        UIAppFonts = 
                        {
                                "Helvetica.dfont"
                        },
                        UIPrerenderedIcon = false
                                                
                },
        },
        
        android =
        {
                versionCode = "13"
        },        
        androidPermissions =
                {
                "android.permission.INTERNET"
                },
}

w2md
User offline. Last seen 4 years 4 weeks ago. Offline
Joined: 18 Oct 2010

Ah, I was also getting errors because there is no "portraitRight" orientation, and corona does not support orientation changes for Android anyway.

dhw688
User offline. Last seen 5 years 33 weeks ago. Offline
Joined: 24 Sep 2011

I know this was suppose to be simple, but I can't seem to get it to work.

I am on Windows 7 and building an app for Android. I do have the JDK installed. But I do not know how to link the keytool command to Corona.

I go around this problem by going to the comman prompt and changing the directory to where the keytool batch file lies (in my cases it is in some C:\Program Files\java\....\bin). I than type in the keytool command as indicated in this post and everything seem to work. The difference are:
* It ask me for more details after the password, including my full name, organisation unit/name, city, state etc...
* When it came to generating the certificate it ended with a 'Access is denied' error.

Than, I could go no further. Any clues would be appreciated.

Kind Regards.

MichaelAssadi
User offline. Last seen 4 years 3 days ago. Offline
Joined: 20 Jan 2011

Hello Ninjapig,

If you have our game and it's up and running on the IOS devices will it be the same for android? Including Openfeint, etc.... Because my game is currently running on IOS but not android, so will it be a hassle to change to android?

Thanks for your help!

MichaelAssadi
User offline. Last seen 4 years 3 days ago. Offline
Joined: 20 Jan 2011

Sorry if I did not explain very thorough.

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

@dhw688

You have to set up your path variables. There is a full tutorial here:
Video Tutorial: http://www.youtube.com/watch?v=extCL1UU5wk
Corona Reference Documents: http://developer.anscamobile.com/reference/installation-and-setup-windows

@MichaelAssadi

I have OpenFeint in my Android games and they work fine. I'm pretty sure that both iPhone and Android OpenFeint code is the same. Just make sure to make your OpenFeint app ID is the same as your Android application you made on the OpenFeint website.

Regards,
Jordan Schuetz
Ninja Pig Studios

dhw688
User offline. Last seen 5 years 33 weeks ago. Offline
Joined: 24 Sep 2011

Thank you ninjapig123 for your links. They were indeed very helpful. My app is now in the market. Thanks.

Kind regards.

KenRogoway
User offline. Last seen 1 year 15 weeks ago. Offline
Joined: 17 Jan 2011

@kam187,

Where do you show your ads? Do you have ads after each level, or during the game, or someplace else?

kam187
User offline. Last seen 3 years 24 weeks ago. Offline
Joined: 10 Sep 2010

If you look at the video i'll explain. (The video is the paid version so doesn't have ads)

http://www.youtube.com/watch?v=jpeHTRFM1_8

I have an admob banner ad 320x48, centered at the bottom of the screen. Its displayed on the main 'walkabout' title screen (where you see the blue play button). There's no ad on the level selector or the loading screen, no when the princess pops up. Once the princess disappears I display the banner ad in the same place, bottom center again. It disappears at the end of the level.

I'm using my admob hack, and refreshing the ad ever 30 seconds.

juliusbangert
User offline. Last seen 1 year 4 weeks ago. Offline
Joined: 19 May 2011

Thank you for laying out these three simple steps, the official android documentation is convoluted and difficult to read. It took me ages to find this forum post.

I think this information should be included on http://developer.anscamobile.com/content/building-devices-android.

Emerson Hsieh
User offline. Last seen 1 year 4 weeks ago. Offline
Joined: 9 Mar 2011

Thanks! I always had trouble signing my app! This post helped me a lot!

wesam charkawi
User offline. Last seen 9 weeks 1 day ago. Offline
Joined: 20 Jan 2011

Hi Jordan

If i have created an app for i-phone using my mac, can i simply create a file using carona for android. If so, how?

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

You sign your application on Mac the same way as you sign it on Windows @wesamcharkawi

mroberti
User offline. Last seen 2 weeks 1 day ago. Offline
Joined: 20 Nov 2010

Dude you're a Godsend!! I was banging my head on how to do this for a little bit and I remembered there was this thread floating around out here with ALL the answers. Totally cool of you Ninja Pig!!

PS I heard you on the IndieGameDev podcast, that was a killer show! Glad you got some exposure!

-Mario

wesam charkawi
User offline. Last seen 9 weeks 1 day ago. Offline
Joined: 20 Jan 2011

Jorden,

Is there a step by step guide for mac users. For example, what to place in the main.lua if anything and the terminal window (which one are you referring to?).

Naomi
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 6 Jun 2011

[Solved] I did not need to install JDK. It's already installed anyway. After reading more and felt exasperated, I thought, maybe, I should just try what I do when all fails -- that is, rebooting my Mac. Who knows, it might just clear out whatever got screwed along the way. And OMG, it did. I gave it another shot at launching Terminal.app (from Applications > Utilities), and then followed step #10 from below, and this time, no error occurred. I am able to confirm I've got my keystore on my machine too (by searching for ".keystore" using Finder). Glad I didn't just give up. Whew.

----------

Ugh, I got keytool error: java.io.FileNotFoundException: mygame.keystore (Permission denied).

I use Mac, and here's what I've done so far:
1) Installed Android SDK Tools
2) Installed Android SDK Platform-tools
3) Installed some of Android 2.2 (API8):
* SDK Platform
* Samples for SDK (probably wasn't necessary)
* Nookcolor
* Google APIs (probably wasn't necessary)
* GALAXY Tab
4) Installed some of Android 2.3.3 (API 10):
* SDK Platform
* Samples for SDK (probably wasn't necessary)
* Nook Tablet
5) Successfully installed & launched myGame.apk on Nook (and Kindle)
6) Read through this thread (thank you, Ninja Pig and all the others) as well as other threads I found.
7) Launched Terminal.app
8) Typed:
sudo keytool -genkey -v -keystore mygame.keystore -alias mygamealias -keyalg RSA -validity 999999
9) Could not get past the password prompt.
10) Tried this next:
keytool -genkey -v -keystore mygame.keystore -alias mygamealias -keyalg RSA -keysize 2048 -validity 999999
11) It asked me to enter keystore password, and then re-enter new password
12) With a great sense of relief, I answered whole list of questions, including my name, my organization, my location.
13) It finally spat out the list of my answers and asked if it's correct.
14) I typed yes and hit enter
15) It asked for key password for mygamealias (and told me to RETURN if same as keystore password), so I simply hit enter.
16) Then it began storing mygame.keystore -- then came the error:

java.io.FileNotFoundException: mygame.keystore (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:194)
at java.io.FileOutputStream.(FileOutputStream.java:84)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:902)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)

What do I do now? Do I need to install JDK before this error goes away?

Naomi

wesam charkawi
User offline. Last seen 9 weeks 1 day ago. Offline
Joined: 20 Jan 2011

This post is a great one.

Skatan
User offline. Last seen 1 year 50 weeks ago. Offline
Joined: 11 Jan 2011

Very useful! Thanks for this!!

lwat4ever
User offline. Last seen 5 years 6 weeks ago. Offline
Joined: 23 Nov 2011

Hi,
I still can't figure this out. I followed your instructions, but don't quite understand what happens next. I know I successfully created the signature, because I just tried to do it again and got this message:

keytool error: java.lang.Exception: Key pair not generated, alias already exists
java.lang.Exception: Key pair not generated, alias already exists
at sun.security.tools.KeyTool.doGenKeyPair(KeyTool.java:1129)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:786)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)

But now that it is created, how do I make it show up in Corona when I do the android build. It is still only giving me one option... android debug.

I'm on a MAC using Lion.
Thanks!

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

@lwat4ever
What ever you named your keystore, just click browse, then search that name on your computer. It will be on your Mac HD hard drive, then Users, Name, android-sdks.

Regards,
Jordan Schuetz
Ninja Pig Studios

OwenYang
User offline. Last seen 46 weeks 4 days ago. Offline
Joined: 22 Jan 2011

@Ninja Pig Studios
I do have a problem it harass me so much!!
i have signed android apk by debugkey and realkey.

i don't see why i run the app on real device(android)
Sometimes it's text disappear.
just like a "display.newRect()"
color is whole black...
sometimes i move it and the text come back again become normal.
sometimes it disappear again...

I have tried set
"android.permission.INTERNET",
"android.permission.ACCESS_FINE_LOCATION",

but in vain

I'm using Corona version 806(tried 704,7XX)
am i wrong somewhere?
or something i have forgotten to set?

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

@coolseal

It seems like everything you did in the build process is correct. If the app runs on the device, then you did everything correct. Looks like your problem lyes in your coding, you should probably check when you are removing display objects etc. Also try using a recommended build and see if that helps.

Regards,
Jordan Schuetz
Ninja Pig Studios

Jazzybossa
User offline. Last seen 1 year 48 weeks ago. Offline
Joined: 30 Sep 2011

Hey Ninja Pig - great tut. With regards the password, what one is it? I may have jumped part of the procedure.

I downloaded the SDK to desktop (which it looks like I don't need by what you say), opened the terminal and typed in the magic words. So I haven't created a password yet - have I?

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

No you create the password!

Regards,
Jordan Schuetz
Ninja Pig Studios

Jazzybossa
User offline. Last seen 1 year 48 weeks ago. Offline
Joined: 30 Sep 2011

Hi - I'm getting an invalid password error. I'm on MAC lion, so I presume I include the sudo at the start. Is there anything in this keystone name that's causing a prob:

themusiciansofbremen.keystore

is it too long? Thanks

Jazzybossa
User offline. Last seen 1 year 48 weeks ago. Offline
Joined: 30 Sep 2011

Got it to work by not using sudo. Am using Mac, last thing I tried!

olgunuckun
User offline. Last seen 5 years 6 days ago. Offline
Joined: 16 Dec 2011

This is super great topic Ninja Pig Studios! Thanks for it.

max3
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 5 Aug 2012

Thanks Jordan. Very helpful !

egarayblas
User offline. Last seen 3 days 22 hours ago. Offline
Joined: 9 Mar 2011

Thanks @Ninja Pig Studios! This is a time saver! :)

ken4
User offline. Last seen 3 years 19 weeks ago. Offline
Joined: 27 Jun 2011

Hi, I've got my app working now on a few Android devices with the zoomStretch fix NinjaPig mentioned. Thanks for all the hopeful notes here. I have next to generate my own keystore to use so hopefully that will work fine. In the meantime I have 2 questions:

- when I download the app on the various Android devices the icon shown is the Corona one. Is this always the case when building in debug mode with Corona's provided debug settings?

- when I use the keytool command to generate my own key, what name should I use for the 'mykeystore.keystore' param's 'mykeystore' field? Is the the actual app name (without spaces, etc.) or is it the package name filled in the Corona build dialog (i.e. com.mydomain.apps.testapp)?

Thx!

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

For the Corona Icons, create the Icon-hdpi.png and Icon-mdpi.png in your root directory in Corona. For the keystore name, name it the name of your app ("AnnoyingPigGame.keystore"). Hope that helps.

ken4
User offline. Last seen 3 years 19 weeks ago. Offline
Joined: 27 Jun 2011

NinjaPig, thanks for the reponse! The icon shows up now properly on the device (Galaxy Nexus in this case) though it's pretty small. I included all three icon sizes at the resultions indicated on the Corona tutorial page (the largest is 72x72 pixels). Is that correct?

Cheers!

Ken

Ninja Pig Studios
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 26 Jan 2011

That should be good. I'm pretty sure there is an xhpi one too, there are 4 different icon sizes.

ken4
User offline. Last seen 3 years 19 weeks ago. Offline
Joined: 27 Jun 2011

Seems that there is also an Icon-xhdpi.png file (96x96 pixels) which isn't mentioned on the Corona page. I'll try adding that!

rxmarccall
User offline. Last seen 2 years 41 weeks ago. Offline
Joined: 18 Jan 2011

@ken4,
I think I had the same issue just a few days ago that you are talking about. On my Galaxy S3 I had all the requried icons, but in the app icon when viewed on the phone was smaller than all the others. I ended up making a xhdpi icon and that seems to have done the trick. supposedly that icon is just for "tablets" but a lot of these new smart phones have REALLY high resolution so they might be considered a "tablet". I am at work right now so I can't remember the Size that I needed to make that one. I believe you just title it "icon-xhdpi" though.

Arsalan
User offline. Last seen 2 years 14 weeks ago. Offline
Joined: 8 Sep 2012

I am getting this error. please help me out, folks. :/
keytool error: java.io.FileNotFoundException: HighwayRun.keystore (Access is den
ied)
java.io.FileNotFoundException: HighwayRun.keystore (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:194)
at java.io.FileOutputStream.(FileOutputStream.java:84)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:902)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)

C:\Program Files (x86)\Java\jdk1.6.0_31\bin>

Rob Miracle
User offline. Last seen 14 hours 38 min ago. Offline
Staff
Joined: 26 Nov 2012

You probably don't have write access to the folder you're trying to create the keystore in.

In fact it looks like you are in the Java bin directory which is probably write protected from non-admin users. You can either CD to a directory where you have write access, like your desktop, documents directory or the projects folder where your project lives and then execute the command to generate the keystore from there. Or if you feel you have to run it from the bin directory, specify a path in front of the keystore name that will put it in one of those writable directories.

Regarding Android Icons. Corona SDK has only recently started supporting the Icon-xhdpi.png icon, but the latest Stable build (971) should have it, the previous stable (840) does not. The Android icons are:

Icon-ldpi.png 36x36
Icon-mdpi.png 48x48
Icon-hdpi.png 64x64
Icon-xhdpi.png 96x96

http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html

Arsalan
User offline. Last seen 2 years 14 weeks ago. Offline
Joined: 8 Sep 2012

Thanks Rob, u have performed a miracle. :D
i have generated the keystore file for my game. Now sir kindly guide me wat do i have to do next in order to make my game integrated with fb? and i have made the developers account on fb and have entered the details except the hash key. thanks!

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.