Adobe Flash Builder 4.6 : Flex Mobile - How to Integrate AdMob - Interstitial for Android
Test on:
- Mac OSX Yosemite
- Adobe Flash Builder 4.6
- Adobe AIR SDK (without new compiler)
- Asus Zenfone 4.5
- ANEAdMob Build3.6 : http://sh.st/U5NlH
[Sample Source Code]
Apk file:
Fxp file:
[Pre-Require]
download and install from any their instructions.
- Adobe Flash Builder 4.6
http://www.adobe.com
- Adobe AIR SDK (without new compiler) [3.6 or Above]
[version 3.6]
http://airdownload.adobe.com/air/mac/download/3.6/AdobeAIRSDK.tbz2
[all version]
https://helpx.adobe.com/air/kb/archived-air-sdk-version.html
- ANEAdMob
https://github.com/pozirk/ANEAdMob
Test on:
- Mac OSX Yosemite
- Adobe Flash Builder 4.6
- Adobe AIR SDK (without new compiler)
- Asus Zenfone 4.5
- ANEAdMob Build3.6 : http://sh.st/U5NlH
[Pre-Require]
download and install from any their instructions.
- Adobe Flash Builder 4.6
http://www.adobe.com
- Adobe AIR SDK (without new compiler) [3.6 or Above]
[version 3.6]
http://airdownload.adobe.com/air/mac/download/3.6/AdobeAIRSDK.tbz2
[all version]
https://helpx.adobe.com/air/kb/archived-air-sdk-version.html
- ANEAdMob
https://github.com/pozirk/ANEAdMob
- Overlay AIR SDK on Flex SDK | Flash Builder
[Create Flex Mobile Project]
1. Open Adobe FlashBuilder and goto File > New > Flex Mobile Project
[Add ANEAdMob]
1. Right-click on project name and choose "Properties".
2. Goto menu "Flex Build Path" and click on tab "Native Extensions" then click "Add ANE..." and "Browse..." to "ANEAdMob/AdMob.ane", click "OK".
3. On menu "Flex Build Path" and click on tab "Library path" then click "Add SWC..." and "Browse..." to "ANEAdMob/air/AdMob/bin/AdMob.swc", click "OK".
[Sample Source Code]
Apk file:
Fxp file:
It's work!! ;)
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob
[Create Flex Mobile Project]
1. Open Adobe FlashBuilder and goto File > New > Flex Mobile Project
2. On tab "Project Location", gave Project name "FlexAdmobAIR46", leave checked "Use default location" and "Use default SDK (currently *Flex 4.6.0)" then click "Next >"
3. On tab "Mobile Settings" choose "Permissions" and select Platform "Google Android", under Permission list check on
[/] "INTERNET"
[/] "ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE"
then, leave other as default and click "Finish".
1. Right-click on project name and choose "Properties".
2. Goto menu "Flex Build Path" and click on tab "Native Extensions" then click "Add ANE..." and "Browse..." to "ANEAdMob/AdMob.ane", click "OK".
3. On menu "Flex Build Path" and click on tab "Library path" then click "Add SWC..." and "Browse..." to "ANEAdMob/air/AdMob/bin/AdMob.swc", click "OK".
[Configuration app.xml]
1. Click on "FlexAdmobAIR46-app.xml" at this line
<application xmlns="http://ns.adobe.com/air/application/18.0">
2. finding after "</initialWindow>" add
For call ane extension like below image.
<extensions>
<extensionID>com.pozirk.ads.AdMob</extensionID>
</extensions>
For call ane extension like below image.
3. finding after permission of "ACCESS_WIFI_STATE" add
<application>
<meta-data android:name="com.google.android.gms.version" android:value="4323000" />
<!-- should be android:value="@integer/google_play_services_version" -->
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
as below images.
[Implement AdMob in mxml]
1. Open "AdmobFlexAIRHomeView.mxml" and add line
creationComplete="Main()" in <s:View ... > as below image.
2. After </fx:Declarations> add code
<fx:Script>
<![CDATA[
//...scripting AdMob goes here...
import com.pozirk.ads.admob.AdEvent;
import com.pozirk.ads.admob.AdMob;
import com.pozirk.ads.admob.AdParams;
[Bindable]
private var debugger:String = "";
protected var _admob:AdMob = new AdMob();
public function Main():void {
_admob.addEventListener(AdEvent.INIT_OK, onEvent);
_admob.addEventListener(AdEvent.INIT_FAIL, onErrorEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onErrorEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onCacheEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onErrorEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onEvent);
_admob.init();
//cache interstitial ads here
_admob.cacheInterstitial("ca-app-pub-3940256099942544/1033173712");
}
protected function onEvent(ae:AdEvent):void {
trace(ae.type + " " + ae._data);
}
protected function onCacheEvent(ae:AdEvent):void {
_admob.showInterstitial();
}
protected function onErrorEvent(ae:AdEvent):void {
debugger += ae.type + " " + ae._data;
}
]]>
</fx:Script>
<s:Form>
<s:FormItem label="Error">
</s:FormItem>
<s:TextInput text="{debugger}" editable="false" width="100%"/>
</s:Form>
as below image.
Hint:"ca-app-pub-3940256099942544/1033173712" is dummy id for test
[Deployment and Testing]
1. Connect your Android device with usb cable and don't forget to change mode to "usb debugging" and "unknown resource"
2. Goto menu "Project > Export Release Build..."
3. The "Export Released Build" window shows up, set or leave any filed similar as below, click "Next >".
4. On "Deployment" tab, checked "install and launch application on any connected devices" and select "Export application with captive runtime".
5. On "Digital Signature" browse to your certificate.p12 file, if you don't have it just "Create..." new one (I'm not discover this part). Then type your password of p12 file when did you created.
6. On "Package Contents" make sure you have checked 2 files of Included files.
7. On "Native Extensions" tab make sure your "AdMob.ane" was checked under "Package". Then click "Finish" and waiting until app launch on Android device.
8. If anything goes well, you device should display like this.
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob






















Comments
Post a Comment