Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

A. Preparing the Adobe Air side

MyFlashLabs edited this page Mar 31, 2020 · 8 revisions

Embeding the Admob ANE into your project

implementing the Admob ANE into your AIR project is similar to all the other ANEs you have embedded before. There is nothing special about this one. The only thing that you must consider is that the Admob ANE will not work unless you have added the dependency ANEs to your project. The following dependencies are required to be added to the <extensions> tag of your air manifest .xml file. Here's the complete list of ANEs you need to implement into your project for the Admob to work properly in your Air project:

  <extensions>
	
	<!-- Dependency ANEs https://github.com/myflashlab/common-dependencies-ANE -->
	<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.androidx.arch</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.androidx.core</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.androidx.browser</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.androidx.lifecycle</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.ads</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.ads.lite</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.basement</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.measurementBase</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.gass</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.gson</extensionID>
	
	<!-- And finally embed the main Admob ANE -->
	<extensionID>com.myflashlab.air.extensions.admob</extensionID>
	
  </extensions>

Read the Admob requirements here, to make sure you have all the other requirments setup.

To test if you have successfully embedded the ANE, import com.myflashlab.air.extensions.admob.AdMob; and then call AdMob.init(stage, ""); If you received any error message or your app crashed, it means that there is something wrong in your setup. If that's the case, please watch these videos here on YouTube. In these videos, I have explained all different reasons that might have caused the crash. To help you even more, I can list some of the specefic mistakes that developers make when using this ANEs:

  • Do NOT run the ANE on a simulator. Use a real device.
  • Always use the latest Adobe AIR SDK.
  • Make sure you have copied the iOS frameworks to "YOU_AIR_SDK\lib\aot\stub"

Configuring the AIR manifest .xml file

When you are sure that you have successfully implemented the ANEs into your project, it's time to set the Air manifest file so your app can correctly communicate with the Admob servers.

Manifest setup required for the Android side:
First you need the internet and network permissions so your app can communicate with Admob servers.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Then, you need to add the Google Play Serices meta tag as follow.

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Then include the AdActivity configChanges and themes.

        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

And finally, depending on if you are going to use Admob or Double-Click, you must enter one of the following tags, but not both of them!

<!-- If you are using Admob (must remove the Double-Click meta-data tag) -->
<meta-data
	android:name="com.google.android.gms.ads.APPLICATION_ID"
	android:value="ca-app-pub-3940256099942544~3347511713"/> <!-- Replace with your own APPLICATION_ID -->

<!-- If you are using Double-Click (must remove the Admob meta-data tag) -->
<meta-data
	android:name="com.google.android.gms.ads.AD_MANAGER_APP"
	android:value="true"/>

Manifest setup required for the iOS side: On the iOS side, you need to make sure the minimum iOS version is 10.0

<!-- iOS 10.0 or higher can support this ANE -->
<key>MinimumOSVersion</key>
<string>10.0</string>

<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
</dict>

<!-- If you are using Admob (must remove GADIsAdManagerApp) -->
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string> <!-- Replace with your own APPLICATION_ID -->

<!-- If you are using Double-Click (must remove GADApplicationIdentifier) -->
<key>GADIsAdManagerApp</key>
<true/>