#2391 Android Demo

go4 Thu 15 Jan 2015

I make an Android demo app to explain how to develop Android apps in Fantom.


download apk


Moved to github

SlimerDude Thu 15 Jan 2015

Wow, that looks brilliant! :)

I see you've added a name mangling patch to fan-1.0 to work around the invokespecial problem - good work!

brian Sat 17 Jan 2015

@go4, awesome work! So was that name mangling of private fields the only fix you needed to compiler/emitter to get Fantom to work on Andriod? If so then maybe should work to get that integrated into core. Would make for uglier stack traces, but might be able to fix that to make them pretty in our code.

go4 Sun 18 Jan 2015

Thanks for reply.

The name mangling is an easy way to get it work. As brian said, there are three strategies.

Name mangling and CallVirtual are all needed.

brian Tue 20 Jan 2015

Ticket promoted to #2391 and assigned to brian

I'm actually thinking it might be better to leave the compiler alone as is and try and handle this strictly in the Java emitter. Because private methods by definition can't be dispatched virtually, I think we can actually generate all private methods as static methods and dispatch using invokestatic. Then we don't need name mangling or wrapper methods. When I have some free time I am going to investigate that approach (if anyone wants to try that out please email me and I will work with you).

Jeremy Criquet Sun 8 Mar 2015

Really cool! Thanks for doing this go4!

go4 Sat 22 Aug 2015

I push another patch for Android 5.0 and update the apk.

Android 5.0 take a new runtime called ART(ahead-of-time compilation) to replace Dalvik VM. It reject a abstract class with factory constructor that generated by fantom.

SlimerDude Sun 23 Aug 2015

Awesome work Go4!

brian Sun 23 Aug 2015

Thanks go4, it sounds like the problem is that I was relying on on the JVM to raise an InstantiationError if I called the constructor of an abstract class. But now that is a verification/compile-time error instead of a runtime error. Not sure I like these subtle differences in Andriod. But that is a much easier fix than the name mangling.

I think the proper fix is to go ahead and generate the static factory method so its there, but just have it raise an exception. I pushed a patch which implements this new behavior in the Java bytecode emitter:


Can you try that out and see if it resolves your problem? Thanks!

go4 Mon 24 Aug 2015

Yes, It works!

Jeremy Criquet Tue 25 Aug 2015

Wow, this is exciting stuff. I'm going to have to try it out! Might revolutionize Android app development.

go4 Wed 26 Aug 2015

Thanks, I just do some experimental works. Hope someone can build a real product in Fantom. The IDE support is another gap. If you want to compile from source, I added some doc

Login or Signup to reply.