Adobe Flash Builder 4.5 : Flex Mobile - How to Integrate AdMob - Banner for Android
Test on:
- Mac OSX Yosemite
- Adobe Flash Builder 4.5
- Adobe AIR SDK (without new compiler)
- Asus Zenfone 4.5
- ANEAdMob
[Sample Source Code]
Apk file:
Fxp file:
[Pre-Require]
download and install from any their instructions.
- Adobe Flash Builder 4.5
http://www.adobe.com
- Adobe AIR SDK (without new compiler) [14.0 or Above]
[version 14.0]
http://airdownload.adobe.com/air/mac/download/14.0/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.5
- Adobe AIR SDK (without new compiler)
- Asus Zenfone 4.5
- ANEAdMob
[Pre-Require]
download and install from any their instructions.
- Adobe Flash Builder 4.5
http://www.adobe.com
- Adobe AIR SDK (without new compiler) [14.0 or Above]
[version 14.0]
http://airdownload.adobe.com/air/mac/download/14.0/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
3. Goto menu "Flex Build Path" and click on tab "Library path" then click "Add SWC..." and "Browse..." to "[ANEAdMobRootFolder]/AdMob.ane" but change type from ".swc" to "*.*" you can choose .ane file, click "OK".
6. Goto "[ANEAdMobRootFolder]/air/AdMob/bin/AdMob.swc", drag "AdMob.swc" onto "libs" folder and released.
7. Then ".swc" will automatic add into "Referenced Libraries"

So, this is result you've got, an Error!
3. Paste recently 2 files under your project folder, like below.
sample: cd /Users/poraweeraksasin/Documents/Adobe\ Flash\ Builder\ 4.5/FlexAdmob45
------------------------------------------------------
then press enter.
6. Use adt command like below structure.
------------------------------------------------------
[path to adt file]/adt -package -target apk
-storetype pkcs12 -keystore "[pathToP12]/cert.12"
-storepass [yourPasswordOfP12]
yourApkFileName.apk
"[projectName]-app.xml"
"[projectName].swf"
"./src/[projectName].mxml"
"./src/views/[projectName]View.mxml"
"./libs/AdMob.swc"
-extdir "[projectToRootOfAdmobANE]"
sample:
[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 "Flex45interstitial", leave checked "Use default location" and "Use default SDK (currently *Flex 4.5.1)" 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".
[Add ANEAdMob]
1. Right-click on project name and choose "Properties".
2. Goto menu "Flex Compiler" in text field "Additional compiler arguments" add under "-locale en_US" add "-swf-version=25".
3. Goto menu "Flex Build Path" and click on tab "Library path" then click "Add SWC..." and "Browse..." to "[ANEAdMobRootFolder]/AdMob.ane" but change type from ".swc" to "*.*" you can choose .ane file, click "OK".
4. Expand "AdMob.ane" see on "Link Type : Merged into code", double-click it.
5. On "Link Type" choose "External" from list then click OK.
7. Then ".swc" will automatic add into "Referenced Libraries"

[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 "FlexAdmob45HomeView.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.init();
_admob.addEventListener(AdEvent.INIT_OK, onEvent);
_admob.addEventListener(AdEvent.INIT_FAIL, onEvent);
_admob.addEventListener(AdEvent.BANNER_SHOW_OK, onEvent);
_admob.addEventListener(AdEvent.BANNER_SHOW_FAIL, onEvent);
_admob.addEventListener(AdEvent.BANNER_LEFT_APP, onEvent);
_admob.addEventListener(AdEvent.BANNER_OPENED, onEvent);
_admob.addEventListener(AdEvent.BANNER_CLOSED, onEvent);
debugger = _admob.toString();
// showing here
_admob.show("ca-app-pub-3940256099942544/6300978111", AdParams.SIZE_SMART_BANNER, AdParams.HALIGN_CENTER, AdParams.VALIGN_MIDDLE);
}
protected function onEvent(ae:AdEvent):void {
trace(ae.type + " " + ae._data);
debugger += ae.type + " " + ae._data;
}
]]>
</fx:Script>
<s:Form>
<s:FormItem label="AdEvent">
<s:TextInput text="{debugger}" editable="false" width="75%"/>
</s:FormItem>
</s:Form>
as below image.
Hint:"ca-app-pub-3940256099942544/6300978111", is dummy id for test
!!! DON'T use Export Release Build for exported Apk !!!
Why? if you goto Project > Export Release Build..., like this.
So, this is result you've got, an Error!
[Build Project]
1. This step was VERY important because you need to use everytime when your code was modified, build project help you build new compiled .swf file on time.
2. Goto Project > Build Project, take a look in project folder, you should see "bin-debug" so get to inside and Copy "Flex45interstitial-app.xml" and "Flex45interstitial.swf" (eg. after "build project" you need to copy new complied file every time.)
[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 >". If you have created ".p12" file, so this step not need.
4. On "Digital Signature" if you don't have it just "Create..." new one (I'm not cover this part). If you have created ".p12" file, so this step not need.
5. Open Terminal and use "ADT" command to deploy apk file, goto inside your project folder by command line like below structure.
------------------------------------------------------
cd [path to your project]
sample: cd /Users/poraweeraksasin/Documents/Adobe\ Flash\ Builder\ 4.5/FlexAdmob45
------------------------------------------------------
then press enter.
6. Use adt command like below structure.
------------------------------------------------------
[path to adt file]/adt -package -target apk
-storetype pkcs12 -keystore "[pathToP12]/cert.12"
-storepass [yourPasswordOfP12]
yourApkFileName.apk
"[projectName]-app.xml"
"[projectName].swf"
"./src/[projectName].mxml"
"./src/views/[projectName]View.mxml"
"./libs/AdMob.swc"
-extdir "[projectToRootOfAdmobANE]"
sample:
/Applications/Adobe\ Flash\ Builder\ 4.5/sdks/4.5.1/bin/adt -package -target apk -storetype pkcs12 -keystore "../FlexAdmob45.p12" -storepass [yourPasswordOfp12] FlexAdmob45.apk "FlexAdmob45-app.xml" "FlexAdmob45.swf" "./src/FlexAdmob45.mxml" "./src/views/FlexAdmob45View.mxml" "./libs/AdMob.swc" -extdir "/Users/poraweeraksasin/Downloads/ANEAdMob-master"
------------------------------------------------------
Press enter and wait.
7. When your build was success, you should see like below. But this generate method not include adobe air runtime in your apk file then your devices should install adobe air from Googleplay Store.
An apk file generated in side your project folder, just copy and install on your devices.
8. If anything goes well, your device should display like this.
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob





























Comments
Post a Comment