Now you can download a new version of AdMob ANE which is compatible with the new rules of the AppsStore. The access to UDID is now forbidden and the ANE overcomes this minor problem. For those who have bought the AdMob Extra, please contact us to get your new version too.
For all people with the “not a valid ANE file” issue. Try to install the current JDK. After doing this the error is gone.
Thanks to Martin who found a solution of this odd problem.
NOTE: All comments are linked to the old version of this post. We are doing our best to fix the problem and restore them.
Update(01/2013): Read more about AdMob here.
Huge discount of all ANEs – low prices.
You have struggled with how to integrate AdMob in your AIR project. Here you will find a solution. I will present you an ANE library, which we have developed and used in several projects. Here you will find the latest stable version and short explanations how to use it. The code of the ANE will be published soon.
You can see the extension in our ANE Explorer in Android Market.
How to use AdMob ANE in AIR for Android?
There are several steps which you should do before start writing code.
- You should add the NativeAds.ane file to your flash project. (Project properties -> Flex Build Path -> Native Extensions -> Add …)
- You should put the following permissions in your config file (your-project-app.xml) in the tag.
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Here is what you should add to your main application mxml file.
protected function onAppDeactivate(event:Event):void
protected function onAppActivated(event:Event):void
protected function onAppPreinitialized(event:FlexEvent):void
NativeAds.setAdMode(true);//put the ads in real mode
//initialize the ad banner with size compatible for phones, it's applicable to iOS only
NativeAds.initAd(0,0, 320, 50);
To display an ad in particular view add the following handlers:
<?xml version="1.0" encoding="utf-8"?>
protected function onViewActivate(event:ViewNavigatorEvent):void
NativeAds.showAd(0,DPIUtil.appHeight - 75,480,75);
protected function onViewDeactivate(event:ViewNavigatorEvent):void
protected function onAdReceived(event:Event):void
//Anything behind the ad will be hidden, update your layout to handle this edge case.
trace("update ui's size and position");
Some notes: The ad will be fetched when the view is activated. If there is an ad to be displayed then the event AD_RECEIVED will be dispatched. When the view is deactivated the ad will be hidden.
How to use it in AIR for iOS ?
Keep in mind:
The vertical positioning of the ad banner should be from 0 to 480 , if you are developing for iPhone. In case you want to show the ads at the bottom of your app and you are developing for iPhone 4, you should use the following code:
//Usage: NativeAds.showAd(x, y, widthOfTheBanner, heightOfTheBanner);
NativeAds.showAd(0,480 - 50,320,50);
This code will work fine for iPhone 3Gs too.
This is a simple demo how to integrate the AdMob in your mobile AIR application.
Note: If you are not using Flash Builder 4.6 to build your AIR project, then you should add the following lines in your app-descriptor.xml file.
Update: You can find some documentation of the ANE classes. It’s not ready yet, but many have asked.