FacebookTwitterGoogle+Share

nme – signing for android release

After a few days of working on that simple game I mentioned earlier, and after much deliberation, sighing, and staring at the wall, I decided to try for a release package for android — which I found almost as confusing as I had feared.

Dear future-self, It is possible and this is how you once went about it:

Step 1. Create a private key thing1

Basically, run a command like this from the command line:

keytool -genkey -v -keystore some-filename-of-your-choice.keystore
-alias however-you-want-to-reference-your-certificate-i-think -keyalg RSA -keysize 2048 -validity 10000

(It will be valid for 10,000 days, or ~27 years.)

The directory you run that command in will now have a file called some-filename-of-your-choice.keystore.

If keytool.exe can’t be found, your paths may not be set up correctly (or up-to-date), and you can use the absolute path to the file (it’s in your JDK’s bin directory).

Step 2. Tell NME to use it

I looked around the NME source files for soo long, and it turns out it’s actually really simple!
You just need to add an element to your project’s .nmml (in my case application.nmml):

<certificate path="path/to/some-filename-of-your-choice.keystore" alias="whatever-alias-you-chose" />

The directory the path attribute starts in is bin/android/bin, in your project’s base directory. So if your keystore is there, you’ll have to set path/to/ to some number of ../s, or just use an absolute path.

Here’s the part that confused me (in spec.nmml):

<certificate path="path/to/certificate.crt" password="1234" alias="my-alias" alias-password="4321" />

It went something like this: .cert? [Panic] But, I don’t even have one of those! Good news though, apparently you don’t even need one!

After that, nme does everything for you! (It’ll ask for your passwords as it runs through, after you tell it nme test filename.nmml android).

Step 3. That didn’t work so much

At this point, at least for me, it still didn’t work. Android wouldn’t load the program, always going on about how [INSTALL_PARSE_FAILED_NO_CERTIFICATES] — which, by the way, was blatantly a lie.

Long story, but eventually it took installing JDK 1.6 and using that instead of JDK 1.7.0_1.

I’d completely forgotten that during NME‘s android setup it had asked me where the JDK was. So I just ended up telling it to setup android again, after which I got into a huge mess of things not working — all of which were my fault until:
The file NME was downloading for Apache Ant wasn’t right (I’m assuming the file moved). Not a big deal, I downloaded the file manually and replaced the one NME had downloaded with it before proceeding to the next step in its setup. (Turns out it downloads the temporary zips to the directory you called nme setup android from.)

Once it was using JDK 1.6, everything worked as (in my opinion) it should have worked originally!

The end.


In summary:
1. use jdk 1.6 instead of jdk 1.7.0_01
2. run the keytool command
3. add the certificate tag to your application.nmml

 

Comments

  1. Ted says:

    Useful post. Thanks for posting this and the other HaxeNME + Android + Java tips.

You must be logged in to post a comment.