Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
2

AIR 3 Native Extensions for Android - Including 3rd party libraries

New Here ,
Oct 11, 2011 Oct 11, 2011

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:

  1. Successfully created native Android library, using compiled-in imports from 3rd party Android library XYZ.
  2. Exported Android project as JAR file
    1. Note, that the referenced 3rd party JAR is in /lib inside the jar.
  3. Successfully created ActionScript library (SWC) to interface with native Android library.
  4. Created ANE package from SWC, extension.xml, Android JAR, and library.swc (for platform Android-ARM, extracted from SWC)
    1. Note: Have also tried putting the 3rd party library in file structure outlined here: http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-2482335412ffea65006-8000.html#WSf26877....  I think this is more geared to runtime type execution with JNI or whatever, so that article has left me a little confused.
  5. Used ANE in example Flex Mobile project.
  6. Built and installed APK file on test DroidX device.
  7. Can successfully see AIR application loading (and trace statements) in LogCat "ActivityManager: Displayed com.me.androidapp/.AppEntry"
  8. 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"
  9. 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.

TOPICS
Development
6.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2011 Nov 08, 2011

Ran the exact same test as you described and came to the exact same conclusion.

It's maybe an other problem, but I even can't have ressources embbed inside the resulting apk! : http://forums.adobe.com/thread/922917

I guess there's an option in the command line to add libraries and the ressources that me missed. I mean there have to be one...

Is there anybody in there who can help us? If the ANE are just for one class java programs, it lowers the interest a bit.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 13, 2012 Jan 13, 2012

dlbromen, I'm also looking for the same thing!

I have many libraries that I want to integrate with, but can't with the same reason...

do you have a solution?

I know that it is possible! you can google for AdMob extension from milkmangames, they integrated with the Google library (Jar) and it's working for them....

anyone, anything would do!

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 21, 2012 Jun 21, 2012

Hello,

The solution is pretty simple.

Just extract the jar and bundle the extracted files with your compiled classes. You will have one final .jar file which will contain the library's content and all your classes.

You can check our version of AdMob ANE here - http://lancelotmobile.com/blog/admob-ane

The whole code is public so you can see the whole 'magic'.

Best regards,

Emil

Lancelotmobile Ltd.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 17, 2012 Dec 17, 2012

Just extract the jar and bundle the extracted files with your compiled classes.

i want to ask how to do this.

i met with the same problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2012 Oct 28, 2012

http://code.google.com/p/flash-for-mobile/

qq讨论群:56892018

version for android http://code.google.com/p/flash-for-mobile/

version for iphone and ipad https://github.com/lilili87222/admob-for-flash

this is a actionscript native extension for developer to ad advertisement to their air mobile application run on iphone or android.it very easy to use

admob for flash android this lib enable you to add admob ad to your flash air application to add native advertisement to your actionscript3 application you just need to do four step

1.replace D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.1\lib\android\lib\resources\android-res.jar with android-res.jar

2. add this config to -app.xml

<android>
<manifestadditions>
<![CDATA[
<manifest android:installLocation="auto">   
<uses-sdk android:targetSdkVersion="11"/> <uses-sdk android:minSdkVersion="8"/>   
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<!-- <activity android:name="com.google.ads.AdActivity?" android:configChanges="keyboard|keyboardHidden|orientation"/> --> <activity android:name="com.google.ads.AdActivity?" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>

Unknown end tag for </manifest>

]]>
</manifestadditions>
</android>

3.add this config to -app.xml

<extensions>
<extensionid>
so.cuo.ane.Admob
</extensionid>
</extensions>

4. add code to your android air application like follow 

test1(); private function test1():void {   
var admob:Admob=Admob.getInstance(); if(admob.isSupported){   
admob.setUnitId(gid); admob.dispatcher.addEventListener(AdEvent?.onReceiveAd,this.adHandler); admob.dispatcher.addEventListener(AdEvent?.onFailedToReceiveAd,this.adHandler);

// admob.showRelation(AdMobAlignment?.ALIGN_BOTTOM,AdType?.BANNER); 

admob.show(50,100,AdType?.BANNER);
}else{   
trace("not support");
}
}

protected function adHandler(event:AdEvent?):void {   
trace("receive ad");
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 17, 2012 Dec 17, 2012

have u found the workaround?

i met with the same problem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2012 Dec 18, 2012

Extracting it - rename the jar file file to .zip and then use your favorite

tool to excitat the content of the zip. Then you should copy and past the

content of the zip on ton of your binary classes (they are usually located

in bin directory).

Final step create jar file from your binary classes, but include the newly

added files too.

I hope this will help.

Sent from my iPad

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2012 Dec 18, 2012
LATEST

thank u,i get it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines