[iOS & Android] AdMob Extension [2.1] [DEPRECATED]

Abliblablobla

  • *
  • Posts: 524



AdMob Extension for Stencyl!

IMPORTANT
A new version of this extension is available here. The AdMob Extension [2.1] will no longer work from August 1st. Any game using this extension and published before August 1st will continue to work and receive ads, but any new game published after that date will require the new version of this extension.

What is it?
This is a whole new AdMob extension that lets you use the AdMob Ad Network without a single line of code!

Key Features
- Cross-platform extension that works on both iOS and Android!
- Easily integrate AdMob Banner Ads!
- [NEW!]Easily integrate AdMob Smart Banner Ads!
- Easily integrate AdMob Interstitial Ads!
- Latest AdMob SDK for Android! (SDK version: 6.4.4)
- Latest AdMob SDK for iOS! (SDK version: 6.6.0)
- Supports Android 2.3.x or higher!
- Supports iOS 6.x or higher!
- iOS 7.0 ready!

AdMob Guide
I have written a guide for this extension and I strongly encourage everyone who wants to use it to read this guide as it contains a lot of useful information about how to use this extension. Please note that this guide is not complete as it is a work in progress. Any feedback is much appreciated: if there are any errors, paragraphs that need improvements and suggestions, feel free to tell me about them!

Sample Game
If you want to take a closer look at how this extension works, you can download the sample game I have created. It shows how to use the provided blocks and you can play with them to see what changes. If you want to test the AdMob extension on your setup, please use this sample game: you can help me a lot with testing, so feel free to report any bug you find!

How to install
If you go under Settings > Extensions, in the top-right corner there is a "Install Extension" button. Click it and choose admob.zip.

IMPORTANT:
This warning is for everyone who had access to the beta of Stencyl 3.0. If you installed the official public version of Stencyl you don't have to worry about anything.
 --> This extension works only if you have a version of Stencyl 3.0 Beta Nightly (OpenFL version). This extension does not work with Stencyl 3.0 Beta Stable (NME version)!

ChangeLog:
- AdMob Extension for Stencyl
          April 11th 2014: Small fixes
          November 28th 2013: [NEW 2.1!] AdMob Smart Banners and small fixes
          November 10th 2013: [2.0] Initial release
- Guide for AdMob Extension
          January 12th 2014: New chapter "Tips & Tricks", Smart Banner description, small improvements.
          November 10th: Initial release (not complete)
- Sample Game for AdMob Extension
          November 10th: Initial release

« Last Edit: February 02, 2015, 11:08:06 am by Jon »
.: BuruBuru :.

Abliblablobla

  • *
  • Posts: 524
@Jon
I suggest to drop support for the previous version of this extension (v1.1) as I have a strong feeling that it is not going to work anymore once the OpenFl branch becomes the official one.

« Last Edit: November 10, 2013, 12:13:43 pm by Abliblablobla »
.: BuruBuru :.

Jon

  • *
  • Posts: 17524
Thanks, I'll do that after we merge the branch in.

sandsoftimer

  • Posts: 316
It's a awesome news Abliblablobla. i just hate iAd for limited support. Thanks for sharing.
iOS ->          

Android ->
iOS -> Bubble Tapping
 Android -> Bubble Tapping


jeffersonshen

  • Posts: 35
Some bugs and fixes:

For iOS, it doesn't compile when the project name has a space.

For android, you need to

1.for admob_directory/include.xml
a.change extension: include.xml -> include.nmml
b.add .jar extension:
     <template path="template/android/libs/GoogleAdMobAdsSdk-6.4.1" rename="libs/GoogleAdMobAdsSdk-6.4.1" if="android"/>
->  <template path="template/android/libs/GoogleAdMobAdsSdk-6.4.1.jar" rename="libs/GoogleAdMobAdsSdk-6.4.1.jar" if="android"/>


2.delete the following lines from include.nmml in pre-installed ads extension folder (stencyl_directory/plaf/haxe/extensions/ads)
    <java path="project/android" />
    <template path="template/android/libs/GoogleAdMobAdsSdk-4.0.3.jar" rename="libs/GoogleAdMobAdsSdk-4.0.3.jar" if="android"/>

3.replace the following code in stencyl_directory/plaf/haxe/lib/openfl-native/1,1,4/templates/android/template/AndroidManifest.xml
    <activity android:name="com.google.ads.AdActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="orientation|keyboard|keyboardHidden" />
>>replaced with>>
    <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

4.(optional) makes the ad adapt to the screen size
change the following line in admob_directory/project/android/MyAdmob.java
     adView = new AdView(activity, AdSize.BANNER, code);
->  adView = new AdView(activity, AdSize.SMART_BANNER, code);

Abliblablobla

  • *
  • Posts: 524
Thanks jeffersonshen for your feedback!

About iOS: Are you running on Mac OS X 10.9 (Mavericks)? If so, the problem you mentioned isn't related to this extension. Jon wrote he was going to fix that but I don't know if he actually had the time to do so.

About Android:

1) I will look into it. I probably forgot to write the ".jar" part. I'm not sure about the "xml vs nmml" change. Looking at the official OpenFL documentation, it clearly states that it is "include.xml" and not "include.nmml" (nmml should be fine too, but it could be an NME leftover).

2) Look at the second and third post of this topic. The previous ads extension will be replaced with this one (?) or a modified version of this one once Jon finishes more important things, so this won't be a problem.

3) Unfortunately I don't have any kind of control over AndroidManifest.xml. I can change it manually, but I cannot change it from the extension itself, and this means that every user who uses this extension has to manually modify his/her AndroidManifest. OpenFL 1.1 has a new architecture that lets you merge multiple AndroidManifests, but I couldn't find some documentation about how to use this new architecture. I have asked here http://community.stencyl.com/index.php/topic,25647.30.html if someone knows something about this new architecture, but there is no answer as of now...

4) I took a look at smart banners but as far as I know they are supported only on Android 4+ devices and require more memory. A lot of smartphones are still running on 2.3.x so I thought that normal banners were better. I will update this extension so that a user can decide which banner type (normal/smart) he/she wants to use.

Thank you again for your feedback!
.: BuruBuru :.

Jon

  • *
  • Posts: 17524
3) I haven't found such documentation either, but it's my impression that *somehow*, you can override the default template without having to modify it. I just don't know how you establish that, but it's going to have something to do with the include.xml file.

jeffersonshen

  • Posts: 35
You are welcome, Abliblablobla.

I'm using Mac OS X 10.8, and it doesn't compile after I installed the extension, maybe it's a bug of openfl, I'm not sure.

1)I can't remember if it's necessary to change to nmml extension, but it works for me anyway, so I put it there just in case. ;)

jeffersonshen

  • Posts: 35
4)It seems like smart banner is working on Android 2.3 as my tester got the ads and her Android version is 2.3.5. But it's great to provide options as some people may not like the padding.

Abliblablobla

  • *
  • Posts: 524
I have just updated this extension to v2.1. In this version I have added support for AdMob Smart Banners for both iOS and Android, so you can chose if you want normal banners or smart banners when showing a banner.

I have also found a workaround for the AndroidManifest.xml part. In this extension there is an AndroidManifest that will replace the existing one so that you don't have to manually modify it. I tried this workaround and it seems to work, but I know that this isn't a good practice.
.: BuruBuru :.

kuroi

  • Posts: 110
great extension, but I have a question. My game is published to Google Play and it works fine on high end devices but when I play it on low end devices (eg.: Sony Xperia J) I get major lags when ads load (I use banner ads).
Have you noticed this? or maybe I have done something wrong with the ad implementation?
(I load a banner in an event, when created... normal ad)

Jon

  • *
  • Posts: 17524
Abi can answer this better than I can, but I assume that some CPU is used to download and load the ad. I'd assume it's normal, and this happens to iAds too.

kuroi

  • Posts: 110
Thanks for the reply Jon, yea it is probably CPUs role to load the ads. Unfortunately low end devices are in majority now. I will wait for Abli's answer before trying to solve this on my own.

Konig Studios

  • Posts: 76
I'm having an issue when my game loads, it just crashes.

I have everything set up per the instructions and the splash screen loads, then crashes the game.

I have a "load banner ad...." block with a "when created" at the beginning scene.

If i remove the admob block, its starts up fine.

iOS 7

« Last Edit: December 26, 2013, 10:15:24 pm by Konig Studios »