With all the new hype surrounding native extension support in AIR 3, I haven't found a single thing that confirms or denies it is possible to include and use an external JAR inside the native Android implementation.
All of the examples basically showcase the ability to hook into the built-in Android APIs. But what if someone wants to use one of hundreds of libraries that make it easier? Certainly it seems like this should be possible. I'll try to outline what I've done and maybe someone will spot a flaw:
- Successfully created native Android library, using compiled-in imports from 3rd party Android library XYZ.
- Exported Android project as JAR file.
Note: The referenced 3rd party JAR is in /lib inside the jar.
- Successfully created ActionScript library (SWC) to interface with native Android library.
- Created ANE package from SWC, extension.xml, Android JAR, and library.swc (for platform Android-ARM, extracted from SWC).
Note: Have also tried putting the 3rd party library in file structure outlined here: http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-24823354 12ffea65006-8000.html#WSf268776665d7970d-6be13ace1308aaebeca-7fff. I think this is more geared to runtime type execution with JNI or whatever, so that article has left me a little confused.
- Used ANE in example Flex Mobile project.
- Built and installed APK file on test DroidX device.
- Can successfully see AIR application loading (and trace statements) in LogCat
"ActivityManager: Displayed com.me.androidapp/.AppEntry"
- Can successfully see native Android Java code being invoked via runtime by AIR app to instantiate extension & context.
"mye_native: MyExtension.initialize", "mye_native: MyExtensionContext.createContext"
- As soon as AIR app tries to call native function, it blows up, not able to find the classes from 3rd party Android library:
E dalvikvm: Could not find class 'com.thirdparty.SomeClass', referenced from method com.me.nativeExtentions.MyExtensionFunction.call
Any ideas? It seems like it should work this way.
One thing I have noticed is that when I blow apart the APK and Dex from a pure Java Android app of mine (that also has 3rd party android libraries), it appears that the classes from the 3rd party have been included inside it (not just a jar reference).
When I do the same thing with my Flex APK, I find only my own Java classes plus Adobe's, and the 3rd party ones are nowhere to be found that I can see.
I posted this on the Adobe forums, but I thought I'd give the SO think-tank a try. Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…