Monday, April 6, 2015

How to add Admob ANE into the Flash Builder project

If you are first time integrating Adobe Native Extension (ANE) into the Flash Builder project (here, i demo an Andoid project), I bet you would have encountered some issues during debugging.

In this post, particularly, I would like to talk about adding Admob into the Flash Builder project. Since the Admob doesnt officially provide the ANE, here I am using the third-party one in the demo.

 If you have come across the error message such as:

VerifyError: Error #1014: Class so.cuo.anes.admob::Admob could not be found.

OR the error pop up similar to:

Error: Requested extension so.cuo.ane.Admob could not be found.



 then this is the right place to look for.


To revise, there are 2 steps to properly add an Adobe ANE into the Flash Builder (here, it is Admob ANE):

Step 1:

Go to Project Tab -> Properties -> Actionscript Build Path -> Native Extensions -> Add ANE


Step 2: (Which is most of the time overlooked by the beginner)

Go to Project Tab -> Properties -> Actionscript Build Packaging -> Google Android -> Tick the Checkbox of the Package


If you miss the step 2, you will face the errors mentioned.

One more thing, unlike using the Admob jar library in the Java project, the one provided by the third-party doesnt support Admob Ads in the debugging mode. You could only see the Ads coming out if you "Export Release Build".

***Updated***
Following the link provided by Mike Monti, I am also able to display the Admob Ads.
One thing to remind is that, remember to add the following in your xml tags:
<meta-data android:name="com.google.android.gms.version" android:value="4323000"/>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
To produce the Banner ads, you can simply follow the code below:

var adMobManager:AdMobManager = AdMobManager.manager;
if(adMobManager.isSupported)
     {
          adMobManager.bannersAdMobId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
          adMobManager.createBanner(AdMobSize.SMART_BANNER,    AdMobPosition.BOTTOM_CENTER,"BottomBanner",null,true);
          adMobManager.showAllBanner();
      }

Hope this helps.