Saturday, October 8, 2016

Build Android native library with Adobe Air

Leave a Comment

I'm currently working on an Android application built with Adobe Air sdk, in AS3. I was wondering if it's possible to compile a kind of UI library that I can import in a Android native application (Java). Basically, I would like to build my UI with Adobe Air, but the main part of my application with Java, the native way.

What I have in mind is to convert the adobe air-generated APK into a Jar file I would import in the native application project, and call some functions that display something on the Screen.

Is it possible? I think it may be possible, because when I don't import Adobe Air SDK in the application, I must install Adobe Air application with the Play Store to make my application working. I don't find lot of things on Google about that :s.

Thank you for your help.

3 Answers

Answers 1

Yes it can be done (in theory), but hold on to your hat, it's a bumpy ride!

I see it is a very old question, with a new bounty (the questioner has not logged on for 3 years!), but here we go...
This method goes to the heart of how android java apps are constructed and run (i.e. DEX, so it will work with adobe-air or ANYTHING, it is fundamental [general method]). (by the way you use the word native in a confusing way, native is commonly understood to mean the JNI (c++) library element of an app).
You say:

"What I have in mind is to convert the adobe air-generated APK into a Jar file I would import in the native application project, and call some functions that display something on the Screen."

Android programs are compiled into .dex (Dalvik Executable)[now called ART but binary compatible] files, which are in turn zipped into a single .apk file on the device (with other things like the manifest and resources). (unzip a .apk and look inside).

A .jar file contains DEX files (zipped). (unzip a compiled .jar and look inside).

I have done some work like this before, here's a link to a tutorial and coding examples [tested by me] (in android studio + gradle) [custom build elements are usually needed (I also give an ant example)].

See my stack-overflow answer Dynamic loading of DEX files

This in theory answers your question, but it's fundamental stuff, complex and has limitations that make it hard to code and maintain (resources are a real pain in the a**e).

Question: This all seems very complicated and hard !

Yes it is ! It is an increadably silly an difficult thing to do! That is why we invented cross platform frameworks, (and for web based code javascript/css/html5...). Failing that PORT the code.

Answers 2

I am not a Adobe AIR developer at all, however, I have developed a few Android App with both native environment and with some kind of framework (specifically PhoneGap). So, may this can help you.

I don't think that there would be any tool which could directly convert mobile apps build using frameworks like Adobe AIR, PhoneGap or any other HTML5 based framework to a native Android app because technically it is very difficult and unfeasible to do a proper mapping between each and every element of HTML5 (or Flex element in your case) to a corresponding native control or logic. The best you can do is use plugin mechanism provided by your framework to interact with Java and vice-versa and basically that is why the framework is there. For most of HTML5 based frameworks there is a plugin mechanism which allows developer to interact with native functionality (like Background Services, Activity or any other native resource). Even these frameworks are build using the same modular or plugin based approach and there major functionality (accessing Camera, Audio, SD Card etc native resources) works like this. We have to enable that feature before using that in our app.

So, look for plugin type of mechanism in Adobe AIR.

Hope this helps.

Answers 3

Maybe this is a dirty way to help you, but you can :

  1. Install the adobe air program in one computer
  2. Copy the files of the install folder of the adobe air program
  3. Embed all this files in the java application
  4. Install the java application
  5. Save the adobe air files in one folder
  6. Start the adobe air with java (like you will do it with the console, a simple call to YourAirApp.exe)
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment