Developing for Android - Basics, Tips, Resources

271 views
Skip to first unread message

MegaBite

unread,
Mar 29, 2016, 3:51:23 AM3/29/16
to haxef...@googlegroups.com
Hey parteypeople!

I would like to learn about developing games for Android with HaxeFlixel and I wanted to ask if you could help me get started. It already took me some time to find out how to test a project with the AVD, but all I can see is the haxeflixel splash screen and then it goes black. I don't ask you for help in this particular matter, but more for links or suggestions on how to get started, because I couldn't find that much and most things I did find were a little too specific, as in, I didn't understand it because I'm just a hobby programmer and don't know all the basics.

So if you could point me in a direction - any direction really - that I would highly appreciate.
Thank you!
MB

Ohmnivore

unread,
Mar 29, 2016, 6:02:37 AM3/29/16
to HaxeFlixel
Hey! I've been building HF projects for Android for a long time now, I got to know it pretty well. First off, you wanna make sure your OpenFL/Lime/HF versions are compatible. In between releases things get broken - text rendering, icons, things like that. It's just a matter of blindly trying different versions to see which one works.

Here's my current setup:
haxelib set flixel 3.3.11
haxelib
set lime 2.5.0
haxelib
set openfl 3.1.4

Second thing: do you have an Android device? If so, testing your game on the device is pretty easy and a lot faster than using the AVD (at least I find that my computer can't handle the emulation).

I'll go to sleep now but I'll post more tips tomorrow.

LuFe_Mas

unread,
Mar 29, 2016, 4:40:30 PM3/29/16
to HaxeFlixel
How do you setup like that.

On my project.xml I put this:
<haxelib name="flixel" version="3.3.11"/>
<haxelib name="flixel-addons"  version="1.1.1"/>
<haxelib name="flixel-ui"  version="1.0.2"/>
<haxelib name="lime"  version="2.8.0"/>
<haxelib name="openfl"  version="3.5.0"/>

But on the references there is still the newest version with these I a write on project.xml. What gives me compiling errors.

MegaBite

unread,
Mar 31, 2016, 2:19:26 AM3/31/16
to haxef...@googlegroups.com
Hey Ohmnivore, thank you so much for your quick reply! Setting it up like that didn't solve my particular problem, but at least I now know how to set the versions and that this is a working combination, thank you! You're right, AVD is super slow, especially on my laptop, but the thing is, I don't know how to test a project on my device and it's exactly stuff like that I would like to know. I don't even know how to configure the android api target. If you could help me in this matter, I would appreciate it a lot :)


Ohmnivore

unread,
Mar 31, 2016, 3:51:02 AM3/31/16
to haxef...@googlegroups.com
Glad it helped!

Finally made a gist of my Android setup: https://gist.github.com/Ohmnivore/8e91e2be5a2d11ac7e19a91420bdc085

android_key.bat is to make your signing key. Replace -alias mondayofficeninja by your own game's name. Make sure that you don't accidentally commit the generated key to your public repository or accidentally share it. It's top-secret.
android_test.bat connects to your device, then stops your game (if running), uninstalls it (if installed), installs it, and starts it. I connect my device to adb through the network (i believe you have to fiddle with your device's settings to get that working). You can also do it through USB, but my drivers are fucky so network was easier for me.
AndroidManifest.xml is very important, take a look at it. Note that I removed 'android:debuggable="true"' so I can upload the .apk to the Play Store. If you're debugging on Android, then you can include it. But tbh I suggest debugging on a desktop build instead: it's faster and both your .apk and your desktop build share mostly the same c++ code, you're likely to catch the same bugs.
My Project.xml deals with a lot of Android-specific stuff, I also found all the needed icon sizes by trial and error.
Finally there's set_master.bat to set the necessary library versions - I consider it good practice to include something of the sort in every project.

I'm also using API 16 (idk why that one in particular, but hey at least it works). You can download it in the Android SDK Manager. I have jdk1.8.0_60 32-bit and jdk1.6.0_37 64-bit installed. I think the 64-bit one is being used for my HF Android compilation toolchain but I'm not sure.

Good luck! Tell me if anything goes wrong.

Ohmnivore

unread,
Mar 31, 2016, 3:56:05 AM3/31/16
to HaxeFlixel
No you actually have to run that stuff in the command line (I think). Alternatively you can try restarting FlashDevelop, but it's not guaranteed to solve it. Also, if you're on dev flixel branch, type "haxelib dev flixel" to disable it.

Sam Bellman

unread,
Mar 31, 2016, 10:16:12 AM3/31/16
to HaxeFlixel
This is a blog post I found incredibly useful http://www.steverichey.com/dev/openfl-android-tips-and-tricks/
It' a bit old and I couldn't get some of it to work, like the spoofing taps to uninstall the old app, but there is some very good info and tips in there, particularly the info on prepping for release and google store.

Ashiq A.

unread,
Apr 6, 2016, 10:18:20 PM4/6/16
to haxef...@googlegroups.com
Download catlog and look for errors right after you start your game.

Does it run on any other targets normally (Flash, Neko)?

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at https://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/6073ba9d-1e51-4dba-a5f4-16e4f98a4d57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

MegaBite

unread,
Apr 12, 2016, 9:17:04 AM4/12/16
to HaxeFlixel
Thanks for the hint! All I tried is adding a red sprite that fills the screen to the MenuState (So yes, it runs normally on Flash/Neko)
Message has been deleted

MegaBite

unread,
Apr 12, 2016, 9:26:09 AM4/12/16
to HaxeFlixel
Thanks so much for this! I believe I'll still manage to screw something up, but this is a great start! Do you know how to set the API version or how to see what version one is using? I think I installed more than one... Thanks again!

Ohmnivore

unread,
Apr 12, 2016, 9:43:52 AM4/12/16
to HaxeFlixel
You can manage your API versions in Android SDK Manager. Then, in AndroidManifest.xml, you can specify which one you want i.e.

<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="16"/>

MegaBite

unread,
Apr 13, 2016, 4:28:34 AM4/13/16
to HaxeFlixel
Thanks again for the fast reply!!!
Reply all
Reply to author
Forward
0 new messages