COMMUNITY

Native Android app with Haxe dev through hxjava

haxe-java
android

(Marcelo Serpa) #1

I’ve got a small Android app to build, and thought about using Haxe instead of pure Java.

I have seen people doing it in the past, but not sure what the current landscape is. Is it still practical to use hxJava to develop Android apps nowadays? Any pitfalls I should be aware of?


(Jérémy Faivre) #2

If you are building a small app, only for Android (meaning no other platforms), I would not bother using Haxe and would simply follow the standard Android path (Android Studio, Java etc…) because everything is already configured properly, you could use standard Android UI XML stuff if you want to (which would not be easy to access from Haxe code) etc…

It may still be relevant to use Haxe with Android for non-UI stuff, it’s basically just about creating a Haxe project that links with -java-lib android.jar (you may find android.jar in Android SDK files I think). Then add the resulting jar file in your app/build.gradle file of your Android Studio project to use it.


(Marcelo Serpa) #3

Hi Jeremy, thanks for the reply!

If you are building a small app, only for Android (meaning no other platforms), I would not bother using Haxe and would simply follow the standard Android path (Android Studio, Java etc…) because everything is already configured properly, you could use standard Android UI XML stuff if you want to (which would not be easy to access from Haxe code) etc…

I don’t mind using Java/XML for the UI part if that’s easier. I’d prefer to keep the Java code to a minimum though and use Haxe for the rest since I don’t really enjoy programming in Java. Thanks for the suggestion, I’ll try it out.

As a related question, does anyone know if there are any Android apps that were at least partially written in Haxe out there? I know there are plenty that use OpenFL, but what I’m looking for are examples of Android apps that didn’t use any Haxe-specific framework, but just Haxe targetting Java directly.


(Robert Konrad) #4

Not exactly what you were asking for because it’s just part of a framework but here’s some Haxe Android code which works via hxjava: https://github.com/Kode/Kha/tree/master/Backends/Android


(Caue Waneck) #5

I made this some time ago https://github.com/waneck/android_haxe . Not sure if it still works, but back when I did it, it hooked itself into the java build system allowing you to just write haxe code and get it all - autocompletion, everything - even using the R class. If you’re interested in trying it out, I’ll be happy to help if you find any issue