Adobe Flash CS6 : How to Integrate AdMob - Interstitial for Android

Adobe Flash CS6 : How to Integrate AdMob - Interstitial for Android

Test on:
- Mac OSX Yosemite
- Adobe Flash CS6 or above.
- Adobe AIR SDK 13 or above
- Asus Zenfone 4.5
- Android SDK
- ANEAdMob

[Sample Source code & Apk file]
Apk file: 
Source code: 

This topic not discuss about how to install any application, I just want to show you only apart of Adobe AIR - AdMob Integration for Android, If you want to see more on something else, please tell me at the end of this topic.

[Pre-Require]
download and install from any their instructions.
- Adobe Flash CS6
http://www.adobe.com
- Adobe AIR SDK
http://labs.adobe.com
- Android SDK
https://developer.android.com/sdk/index.html
- ANEAdMob
https://github.com/pozirk/ANEAdMob

[Create Adobe AIR Application]
1. Open Adobe Flash and choose "AIR for Android"


2. Then press "command + s", and browse to folder you want to save this project. 
sample: "Test_AIR_ANEAdMob.fla" then I just add text for test when app running on screen you don't need it.



4. In "Publish" panel click an icon "pencil" then type name "Main" and leave button as "Flash Professional" and click ok.


5. An ActionScript was created as below.


6. Add line of code as below images step by step.


6.1 import library.


6.2 implement admob instance


6.3 add listener for admob instance


6.4 create function for any event listener.

7. For this step, I've change function on line "AdEvent.INTERSTITIAL_CACHE_OK" at "onEvent" to be "onCacheEvent". Add last line of code for cache ads, change "ca-app-pub-xxxx" to your admob interstitial id. 


7.1 change function "onEvent" to be "onCacheEvent"


7.2 show interstitial ads

8. Add function for make sure interstitial ads can be cached without error and call show interstitial ads in this function like below image. After that press "command + s", and browse to folder of this project to save Main.as file. 


8.1 add "onCacheEvent" function


[Add ANEAdMob]
1. Extract ANEAdMob.zip then in flash goto File > ActionScript Settings...


2. Add swc file by click on red-f icon and browse.. to ANEAdMob/air/AdMob/bin/AdMob.swc




3. Add ane by click add path [+] icon then click ane icon, after that browse.. to ANEAdMob/AdMob.ane





4. Click ok, now you already to setting application for publish.

[AIR Android Settings]
1. In flash goto File > AIR XX.X.X for Android Settings...



2. On General tab check any value as below. don't forget App ID not allow underscore (_) in name just remove it, Version label only for test you can leave it blank. You should see AdMob.ane in Included files.


3. Just skip Deployment and goto tab "Icons" add at least one icon size, i created simple blue rectangle size 72x72 pixels for test.



4. Goto tab "Permissions" and check on "Manually manage permissions...descriptor file."


5. Goto tab "Languages" check on "English".



[Config Application-app.xml]
Open your "filename-app.xml" and paste this code after end of "</icon>" as below images and saved overwrite this files.

    <android>
        <manifestAdditions><![CDATA[<manifest><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><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></manifest>]]></manifestAdditions>
    </android>

and

<extensions>
        <extensionID>com.pozirk.ads.AdMob</extensionID>
</extensions>

Sample image:

[Publish to Android Device]
1. Goto tab "Deployment" and click "create" if you don't have filename.p12 file, fill any text field with your data, i'm just input sample data then click "Save as" to your project folder.



*If you found this error, please change "Type 1024-RSA" to "Type 2048-RSA", and save again.



2. After saved p12 file, fill in "Password" field and check setting as below image.


3. Connect your android device via usb cable. and click "Publish"


4. When your app has success installed on device, you should see this notice.


5. Let's see on your android device and don't forget to turn on your internet connection, AdMob interstitial was shows up cover overall screen.


[Sample Source code & Apk file]
Apk file: 
Source code: 

It's work!! ;)
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob

Comments

  1. thanks good job

    I want to know how can I import swf game and convert to apk android

    thanks again

    ReplyDelete
  2. Hey man.. I managed to integrate the interstitial ad in my app.. Anyways, may I know if you had managed to integrate banner ad & interstitial ad together in one app? Because I had already tried but it didn't work.. Thanks..

    ReplyDelete
    Replies
    1. This is my example Ads Control, can show/hide by flash button.
      download : "Flash - Ads Control"

      Delete
  3. Nevermind me... I've managed to display both interstitial & banner ads... Hehe...

    ReplyDelete
  4. Sir please sent ane file support in windows7 professional ,flash cs6
    Sdk 18

    ReplyDelete
  5. And source code as3 sent

    Or windows os supporting tutorial in you're blogger

    ReplyDelete
    Replies
    1. You can download air archive version as you want here: https://helpx.adobe.com/air/kb/archived-air-sdk-version.html
      AdMob ane 3.6 support AIR same version and above:
      https://www.dropbox.com/s/6rxz4d00acf572q/ANEAdMob%203.6-master.zip?dl=0

      No as3 sourcecode since no one paid for my job, just do it from tutorial, it's the same result.

      Delete
  6. package com.pozirk.ads.admob
    {
    import flash.events.Event;

    /**
    * Ad events
    * @author Pozirk Games (http://www.pozirk.com)
    */
    public class AdEvent extends Event
    {
    public static const INIT_OK:String = "INIT_OK";
    public static const INIT_FAIL:String = "INIT_FAIL";
    public static const BANNER_SHOW_OK:String = "BANNER_SHOW_OK";
    public static const BANNER_SHOW_FAIL:String = "BANNER_SHOW_FAIL";
    public static const BANNER_LEFT_APP:String = "BANNER_LEFT_APP"; //Called when an Ad touch will launch a new application.
    public static const BANNER_OPENED:String = "BANNER_OPENED";
    public static const BANNER_CLOSED:String = "BANNER_CLOSED";
    public static const INTERSTITIAL_SHOW_OK:String = "INTERSTITIAL_SHOW_OK";
    public static const INTERSTITIAL_SHOW_FAIL:String = "INTERSTITIAL_SHOW_FAIL";
    public static const INTERSTITIAL_LEFT_APP:String = "INTERSTITIAL_LEFT_APP"; //Called when an Ad touch will launch a new application.
    public static const INTERSTITIAL_CACHE_OK:String = "INTERSTITIAL_CACHE_OK";
    public static const INTERSTITIAL_CACHE_FAIL:String = "INTERSTITIAL_CACHE_FAIL";
    public static const INTERSTITIAL_OPENED:String = "INTERSTITIAL_OPENED";
    public static const INTERSTITIAL_CLOSED:String = "INTERSTITIAL_CLOSED";

    public var _data:String; //extra info about event

    public function AdEvent(type:String, data:String = null)
    {
    super(type, false, false);
    _data = data;
    }
    }
    }

    Please Solve This Error

    Line 1 5006: An ActionScript file can not have more than one externally visible definition: com.pozirk.ads.admob.AdEvent, com.pozirk.ads.admob.AdMob

    ReplyDelete
    Replies
    1. the package ANE not wrong, you're newbie in AS3.0 and don't clearly understood about working with ANE implementation, so if you need to done like my sample, you must create new one .fla file and doing step by step like my tutorial, it can be done or vice versa follow my video tutorial part 1- 5 END https://www.youtube.com/watch?list=PLT04nk1_8L9jX9OTYjPzDPkeUINsqqDhO&v=wdWMcsXNPmk

      if you still struggling without base knowledge you're deep getting lost with many error.

      Delete
    2. I don't have a time for every your error issue. My tutorial not create for newbie, it's require basic level of AS3.0 and ANE.

      Delete
  7. hi
    I have a problem with interstitial
    doesn't show
    but banner display good

    ReplyDelete

Post a Comment