Publishing a HaxeFlixel Game on Android

Yesterday I released Pig Jumper on Android via the Google Play.

Pig Jumper Screenshot

It is a Game where you help Piggy jump from one to the next platform. It was originally created for the OneHourGameJam. In this gamejam it is the task of the developer to create a game in one hour. Of course Pig Jumper needed some additional polishing and bugfixing (in the original version you could land on the same platform, which would increase your score) after the one hour in the original jam. Porting it to android also took some time, as the jam version was built for the Flash target of HaxeFlixel.

Publishing on Android

For publishing a HaxeFlixel Game on Android via the Play Store there are some additional steps that need to be performed. You can find all of the information provided here on the internet, but I had not found one comprehensive guide which walks a developer through from beginning to start. Some links I recommend:

I assume a more ore less finished game in HaxeFlixel. We will go through the process step by step.

Setting up HaxeFlixel

At first it is a good Idea to update all HaxeFlixel libraries to the newest version. This is done by typing haxelib upgrade. Confirm the questions to upgrade. With haxelib list you can then get a list of all installed Libraries, including the installed and selected (square brackets) versions.

HaxeFlixel has to setup the Android Target. (If you want more information than provided here, there is a nice guide on the website.) This will take some time as a lot of tools have to be installed. Use lime setup android and follow the instructions. Then you need to select an Android SDK Version in the android virtual device managment software. I choose Version 16, since this works on a lot of devices and is compatible to many devices.

Now you can build your project with lime build android (in the respective project folder). This will work for some time. Don't worry. When you call it the first time, all HaxeFlixel Files will be compiled. After that only files that have changed will be compiled, so the process will be much faster.

In the export/android/bin/bin/ folder there will be a [Project Name]-debug.apk file. To get this working on your Android device, you will need to change the smartphone's settings to allow installation from unknown sources (which is not the official Play Store). The exact location of this property depends on your Android version, but you should be able to find it somewhere in the settings. Then you can copy the created apk to your device (by usb, email or ftp, jst get the file on the phone ;) ) and install it. Congratulations, you have created your first Android game!

Your first Android Game

Signing your apk

You will have noticed that the apk file is named ...-debug.apk. For creating a fully publishable release version, you need to sign the file. For signing you need a key. A key can be generated by a java tool, named keytool. You can find this for example in the java installation, that was done when you were setting up the android target.

Go to the bin folder and type:

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

You should change the placeholders YOUR_RELEASE_KEY and YOUR_ALIAS to appropriate values. Follow the instructions. I suggest to use a strong password that you store some place safe. This will give you a keystore file.

In your project folder create a new folder, called templates and copy the keystore file here. If you use version control, you should not add the keystore file to it, as someone could spoof you app with this file.

Then open the Project.xml file and add the following line in the android section.

<certificate path="templates/YOUR_RELEASE_KEY.keystore" alias="YOUR_ALIAS" password="XXXX" if="android" unless="debug"/>

Again, use the correct values for the placeholders. Make sure to remove the Project.xml from version control as it contains your password in plain text.

If you build your game now, there will be a ...-release.apk.

Setting App Permissions and package name


When installing the app, the phone asked for some permissions, like network, vibrate or wake up. If you are not using any of those features, you should remove them. Actually, google requires you to remove any permissions you do not use.

This can be done by setting up a file called AndroidManifest.xml. You can find a template in your HaxeFlixel folder. I recommend to use the one from samcodes-admob as this is the most complete one.

Copy this file to the template folder. Now you should remove all of the uses-permission lines. This will get rid of the requirements that are not needed.

Package name

Also make sure, to set the correct package name in the AndroidManifest.xml. If you use com.example.myapp you will not be able to upload it to the Play Store.

Using your own AndroidManifest

One additional line is needed in the Project.xmlfile. Again, in the android part, add

<template path="templates/AndroidManifest.xml" rename="AndroidManifest.xml"/>

This will then use your own Manifest file.

Icon and Pictures

For your app to be memorizable, you want to have an icon. This must have a square size, but no further requirements to size. For example using a 100x100 px image is totally fine. I like to store that image in the assets/images folder.

Again in the Project.xml file, add some lines, like those:

<icon path="assets\images\icon_100.png"/>
<icon path="assets\images\icon.png" size="36" if="android"/>
<icon path="assets\images\icon_100.png" size="100" if="android"/> 

You can use different sizes and Haxe will pick the correct one to use. This is very handy.

When it comes to images: You will need some images for the Play Store. This is a little bit of work, since you need them to be of the correct size. You will need one 512x512 image and one 1024x500 image, and some screenshots of arbitrary size. A promotion video or trailer might also be helpful.

Going Live

You need to get a google developer console account. Google requires a 25$ fee (from a credit card) for setting it up. With that account you can then upload the game and create a store entry with all the images and some nice desctiption. You will also need to do a quick survey on how violent the game is.

After providing all this information you press "publish". This will take some minutes. Then you will be able to find you game in the Store.