It was hard for me to be able to make these extensions work together with Haxeflixel 4.3.0 so I’ll write this post in case anyone encounters the same problems.
These are useful tools for android and ios games. I only tested it on android but this also should work on ios.
We are going to implement these libraries:
Google play game services (Achievements and leaderboards)
Admob is an extension to monetize using ads, Analytics is used to measure things about users and Google play games to display achievements and scoreboards.
This is the list of all the libraries once installed. You can look your list doing:
There seems to be a problem if you are using the library hscript for Haxeflixel and compiling the release version. If you have that library, remove it:
haxelib remove hscript
First, If you didn’t do it you need to setup Lime to be able to build apps for android. To do it you need to write:
Lime setup android
Follow the instructions to install the SDK and JAVA but download the NDK separately from: https://developer.android.com/ndk/downloads/index.html
I’m using r16b. This is needed to recompile the analytics extensions later.
Tell lime where you installed ndk with Lime setup android.
When you finished installing the sdk go to the folder where is at and open the sdk manager. Upgrade the android sdk tools and platform tools to 25.2.5 and 27.0.1 respectively.
Then install sdk platform for api 23 and google repository from extras.
We need to recompile hxcpp with the new NDK. To do that execute:
openfl rebuild hxcpp android -clean
For more details on Android Development this is a good tutorial: http://www.steverichey.com/dev/openfl-android-tips-and-tricks/
For admob and Google play install the extensions from Haxelib. I’m using the following versions:
For analytics we need to download the git versión 1.0.0 using haxelib:
haxelib git ganalytics-git https://github.com/emibap/GAnalytics.git
This extension needs to be recompiled using the ndk we downloaded on the previous step. To build it just execute build.bat from the library folder. It will create a folder called ndll.
All these extensions also need extension-googleplayservices-basement to configure the dependencies from the android sdk. The main problem I had was that the tool included on this extension to download new dependencies didn’t worked for me and the only thing that it did was to delete all dependencies. So I needed to install them by hand.
All dependencies installed need to be from the same version to work. So we are going to need to update all dependencies. To do it go to the folder where you installed the sdk and search for the gms. It is on:
Here you have folders for every dependency. Inside you have them by versión number. I’m using version 11.0.4
Inside the version folder you have a .aar file that can be decompressed using WinRar or a similar program.
You need to put the content from the .aar files on the folder dependencies from extension-googleplayservices-basement. The structure for each folder is:
- libs ( here you put classes.jar from the .aar)
- res (Copy it from the .aar )
- src (Copy it from the .aar )
- AndroidManifest.xml (Copy it from the .aar. We need to configure these later)
- build.xml (Copy it from the template folder)
- project.properties (Copy from the template folder)
Do these process for each dependency you need installed. The dependencies I installed are:
After that you need to check if the manifests are fine. Check the manifest for every dependency, if it defines an sdk dependency delete it and on the project.xml for your project add:
<android target-sdk-version="23" if="android" />
The manifest for google-play-services-analytics-impl need to be edited to add a few services needed for the extension:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.gms.analytics">
<!-- Include required permissions for Analytics to run. -->
<!-- Optional permission for Analytics to run. -->
<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
dispatching on non-Google Play devices -->
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
<!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
installation campaign reporting -->
<action android:name="com.android.vending.INSTALL_REFERRER" />
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
Then you need to edit the include.xml from extension-googleplayservices-basement to add the new dependencies. Here is how my file looks:
<?xml version="1.0" encoding="utf-8"?>
Lastly, you need to setup each service from their websites and configure your app using each extension instruction.
I hope all this helps you on your future android games!