OpenFL/Haxeflixel Android Signing APK

ShaunHaxeLeave a Comment

Haxe C++ target

So I am in the process of signing my game for release after using the standard debug.apk throughout the development process (that is automatically applied via OpenFL and Lime).

It is important to know the procedure for my own reference and for anyone who gets confused as I did at first.

First off, you need to generate a private key, this can be done by looking for an executable named keytool in your JDK path. Mine exists at:

C:/Program Files (x86)/Java/jdk1.8.0_51/bin/keytool.exe

On a windows machine, to know where it exists you can type:

where keytool

I change into the directory where this exists and run the following:

keytool -genkey -v -keystore myGame.keystore -alias myGame -keyalg RSA -keysize 2048 -validity 10000

I now have a key called myGame.keystore. I move this file to the root of my project (where the OpenFL Project.xml resides).

MyGame Project

When I have moved this, I first need to add a certificate tag in Project.xml.

I now want to build my project so it gets exported to the export directory. (Or whatever directory you have chosen to export to). So in the root of the project I open the command line and type:

lime build android -clean

The clean argument wipes the directory clean so that any existing exports are removed. If I navigate to the path where this project was transpiled I should see an unsigned release key. I now need to use jarsigner on this to sign the APK. Run this command. If jarsigner is not recognised you will need to add to your path, it can be found under the JDK alongside the keytool executable.

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myGame.keystore "C:/Users/Shaun Stone/Desktop/MyGame/export/android/bin/bin/MyGame-release-unsigned.apk" myGame

One last thing to do. Use the zip align executable, this is found under build tools in your Android SDK path.

"C:/Development/Android SDK/build-tools/23.0.2/zipalign.exe" -v 4 
"C:/Users/Shaun Stone/Desktop/MyGame/export/android/bin/bin/MyGame-release-unsigned.apk" 
"C:/Users/Shaun Stone/Desktop/MyGame/export/android/bin/bin/myGameRelease.apk"

The steps can be found here under manual for Google play:

You now upload the APK (C:/Users/Shaun Stone/Desktop/MyGame/export/android/bin/bin/myGameRelease.apk) to Google play! Woohoo!


Leave a Reply

Your email address will not be published.