Adobe Flash CS6 + Adobe AIR : How to Integrate AdMob - Banner for Android

Adobe Flash CS6 + Adobe AIR : How to Integrate AdMob - Banner 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 Build3.6 : http://sh.st/U5NlH

[Sample Source code & Apk file]

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. Add last line of code for show banner, change "ca-app-pub-xxxx" to your admob banner id. After that press "command + s", and browse to folder of this project to save Main.as file. 


7.1 show banner

[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 banner was shows up on bottom of screen.


[Sample Source code & Apk file]

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

42 comments:

  1. I still fail
    the emergence of even always like this "Error creating files
    Namespace is invalid in the application descriptor file
    "

    ReplyDelete
  2. [SWF] com.pozirk.ads.AdMob - 6941 bytes after decompression
    [SWF] Bismillah.swf - 12689 bytes after decompression
    INIT_FAIL Isn't it clear, that ANDROID Extension will NOT work on PC/Mac???
    ArgumentError: Error #3500: The extension context does not have a method with the name show.
    at flash.external::ExtensionContext/_call()
    at flash.external::ExtensionContext/call()
    at com.pozirk.ads.admob::AdMob/show()[D:\Pozirk\_projects\ANEAdMob\air\AdMob\com\pozirk\ads\admob\AdMob.as:68]
    at Main()[D:\admob\Bismillah\Main.as:32]
    at runtime::ContentPlayer/loadInitialContent()
    at runtime::ContentPlayer/playRawContent()
    at runtime::ContentPlayer/playContent()
    at runtime::AppRunner/run()
    at ADLAppEntry/run()
    at global/runtime::ADLEntry()

    ReplyDelete
    Replies
    1. You must test with publish on real android device only (.apk), AIR extension not work on PC and MAC.

      Delete
    2. BUT admob ads appears as the initial time I try android smartphone

      " You should have declared in the advertising activities AndroidManifest.xml with configchanges "

      Delete
    3. you can control admob by using method show(parameter) or hide() after init()

      Delete
    4. how to do brother? using what applications?
      hehe

      Delete
    5. In section [Create Adobe AIR Application] at step 7., if you follow until to this step 7. _admob.show(parameter) use for show, then _admob.hide() use for hide also, you must create button and call function for show or hide.
      If you still confuse about that i will create sample next time.

      Delete
    6. I wait for the sampel..hehe
      thank you
      if you can make immediate yes

      Delete
    7. In step 7. _admob.show(parameter)... make sure to type "SIZE_SMART_BANNER". Not "SIZE_IAB_BANNER"... Because the sample code in the link https://github.com/pozirk/ANEAdMob is written differently compared to the picture in step 7. Anyways, I've managed to display the AdMob ads... Thank you very much.

      Delete
    8. sorry man
      I am still confused
      can be made sample AdMob banner man??
      thanks

      Delete
    9. [Sample Source code & Apk file]
      Source code: click
      Apk file: click

      Delete
  3. Hi there, I'm planning to include an interstitial ad in my app. May I know what's the code that I should write or add after the sample code below? Thank you.

    //caching and showing interstitial ad
    _admob.cacheInterstitial("AD_UNIT_ID");
    ...
    _admob.showInterstitial();

    ReplyDelete
    Replies
    1. Thank you for your question, I've created sample as you want. Please see on this post Flash CS6 - AdMob Interstitial

      Delete
    2. Thank you very much.. I just checked the sample... It really worked... You're the best man...

      Delete
  4. why after I finished making the application and want to install admob always appeared Scene 1, Layer 'Actions', Frame 1, Line 3 1046: Type was not found or was not a compile-time constant: MouseEvent. ??

    ReplyDelete
    Replies
    1. Please show me your code or send me your link to source code where i can see it.

      Delete
  5. Make my own code in youtube please correct,, please help me to be able to resolve this issue https://youtu.be/748o2WxUvJE

    ReplyDelete
    Replies
    1. That's error happen because you try to add code in Frame 1 of timeline then you add Main class, this error will occur.

      My suggestion is choose only one choice for your project, I think you should move your code from Frame 1 (Drag and Drop) out of that, left it empty and paste into Main.as like OOP style. like this.

      // Main.as

      package {

      import flash.display.MovieClip;
      import flash.events.MouseEvent;// For Drag and Drop


      public class Main extends MovieClip {


      public function Main() {
      // constructor code

      /* Drag and Drop
      Makes the specified symbol instance moveable with drag and drop.
      */

      movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

      function fl_ClickToDrag(event:MouseEvent):void
      {
      movieClip_1.startDrag();
      }

      stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
      }

      // Drag and Drop listener
      function fl_ReleaseToDrop(event:MouseEvent):void
      {
      movieClip_1.stopDrag();
      }

      }

      }

      and so, i've seen you forgot to check permission [/] ACCESS_WIFI_STATE, it's need.

      Delete
  6. Hi, just wanna ask you something... I assume that these configurations steps will not work on iPhones, right?

    ReplyDelete
    Replies
    1. Sorry, I'm never test on iPhone.
      If have something error i remind you follow up to site of ANE might not support on iOS.

      Delete
  7. Hi, I'm having trouble with the .ane extensions that I downloaded from https://github.com/pozirk/ANEAdMob, I downloaded your .apk example and it works fine on my phone so I wondered if you could send me the .ane extension files that you are using? Thanks.

    ReplyDelete
  8. Hello, good work. please how do i solve this problem below. Thanks
    "Error creating files
    Namespace is invalid in the application descriptor file
    "

    ReplyDelete
  9. Hello please send admob full codeing as3.0

    ReplyDelete
    Replies
    1. Just follow my tutorial, you'll got learning skill and work also.

      Delete
    2. Solve this error sir


      Unexpected or unknown element or attribute in the application descriptor file.

      Application.extensions is an unexpected element/attribute


      This error showing app published page

      Delete
    3. AIR Error

      ArgumentError: Error #3500: The extension context does not have a method with the name cacheInterstitial.
      at flash.external::ExtensionContext/_call()
      at flash.external::ExtensionContext/call()
      at com.pozirk.ads.admob::AdMob/cacheInterstitial()[D:\Pozirk\_projects\ANEAdMob\air\AdMob\com\pozirk\ads\admob\AdMob.as:83]
      at Main()[C:\Users\Ananth\Documents\Admob 1\Main.as:45]
      at runtime::ContentPlayer/loadInitialContent()
      at runtime::ContentPlayer/playRawContent()
      at runtime::ContentPlayer/playContent()
      at runtime::AppRunner/run()
      at ADLAppEntry/run()
      at global/runtime::ADLEntry()




      OUTPUT ERROR

      [SWF] com.pozirk.ads.AdMob - 7065 bytes after decompression
      [SWF] Admob.swf - 7447 bytes after decompression
      ArgumentError: Error #3500: The extension context does not have a method with the name cacheInterstitial.
      at flash.external::ExtensionContext/_call()
      at flash.external::ExtensionContext/call()
      at com.pozirk.ads.admob::AdMob/cacheInterstitial()[D:\Pozirk\_projects\ANEAdMob\air\AdMob\com\pozirk\ads\admob\AdMob.as:83]
      at Main()[C:\Users\Ananth\Documents\Admob 1\Main.as:45]
      at runtime::ContentPlayer/loadInitialContent()
      at runtime::ContentPlayer/playRawContent()
      at runtime::ContentPlayer/playContent()
      at runtime::AppRunner/run()
      at ADLAppEntry/run()
      at global/runtime::ADLEntry()



      And solve output error sir please help me

      Delete
    4. this sample is tutorial for banner, i've seen you try to use Interstitial Ads, you should follow this post: Flash CS6 - AdMob Interstitial https://gamedevtodied.blogspot.com/2016/01/adobe-flash-cs6-adobe-air-how-to.html

      Delete
  10. why do you say download android sdk in [Pre-Require]

    ReplyDelete
    Replies
    1. First time i want to test on Android simulator for standard Android OS not refer to real devices but actuallt simulator too slow performance then it's exist in list of pre-require without use, thanks guy, i will update this post soon as google ads is deprecate in 2018.

      Delete
  11. I HAVE ERROR IN main as file
    D:\flashwork\admobe\03-11-2017\main.as, Line 35 1046: Type was not found or was not a compile-time constant: AdEvent.


    protected function onEvent(ae:AdEvent):void
    {
    trace(ae.type+""+ae._data);
    }

    ReplyDelete
  12. am using flash cs6 on windows 7
    my sdk version AIR 26.0.0.118
    i have add ane and swc successfully and also edit xml file also

    ReplyDelete
    Replies
    1. Cool, actually ANE Admob was build via difference version by those guy and i just pick up to make a sample when you use it must carefully about air sdk version, ane admob version and air manifest version and detail.

      Delete
    2. so i need to use different ane file....?
      or what i do?

      Delete
    3. Using latest ANE from here https://github.com/pozirk/ANEAdMob
      It's build with Adobe Air 27, you can take his code as sample build and test.

      Delete
  13. Smartphones play an important role in our life. With smartphones, we always stay connected with our family and friends, capture images, important files, and many more things that you saved... Health

    ReplyDelete
  14. how can i do to show interstitial
    thanks

    ReplyDelete