Admob Extension

Hi everyone!

I have just released Admob extension for OpenFL and would like to share it with you.
You can install it with haxelib:

haxelib install admob-openfl

Before I was using the following extension for Admob:


But it requires lots of actions, like replacing AndroidManifest.xml and GameActivity.java, what I didn’t like.

Mine is much simpler to use, and doesn’t require any special actions.
On the other hand, it doesn’t support iOS. So, if someone wants to add iOS support to the extension, please let me know!

More info on Admob extension and usage here:

2 Likes

Nice work,
This is my first time implementing ads in mobile app and your extension is very beginner-friendly compared to the others.
I have followed the instruction on github and it worked flawlessly when displaying banner ads in my project.
but when I’m trying to display interstitial ads, somehow it’s stuck after calling admob.cacheInterstitial(). and the event AdmobEvent.INTERSTITIAL_CACHE_OK is never connect to the listener function.

Do you have any advice?

Thanks,

Make sure you are using latest version 0.0.2 from haxelib and also you have initialized the extension and received INIT_OK event before calling cacheInterstitial().

I have no problems with both banners and interstitials in my game.
You can check it on Google Play: https://play.google.com/store/apps/details?id=com.pozirk.matchjong
Play level 2 to see interstitial.

1 Like

Thanks for the reply,

I have created a new empty project and implement the library, but the interstitial still doesn’t show up.
maybe it’s the build environment?

here’s my haxelib list :

D:\>haxelib list
actuate: 1.7.2 [1.8.2]
admob-openfl: [0.0.2]
box2d: [1.2.3]
flixel: 3.2.2 3.3.5 [3.3.6]
ganalytics: [0.0.3]
hxcpp: 3.1.30 3.1.48 [3.1.68]
hxlibc: [1.1.4]
hxtools: [1.1.6]
layout: [1.2.0]
lime-tools: 1.2.3 1.3.2 1.4.0 [1.5.7]
lime: 0.9.4 0.9.6 2.0.6 2.1.2 [2.1.3]
openfl-gps-lib: [1.0.2]
openfl-html5: 1.1.0-beta [1.4.2-beta]
openfl-native: 1.2.0 1.3.0 [1.4.0]
openfl-samples: 1.2.1 1.3.0 [2.2.2]
openfl: 1.2.0 1.3.0 1.4.0 2.2.4 2.2.7 [2.2.8]
spritesheet: [1.2.0]
swf: 1.7.6 [1.7.7]

here’s my sdk version

NDK r8b
Android 4.1.2 (API 16)
Android SDK Tools Rev. 24.1.2
Android SDK Platform-tools Rev. 21
Android SDK Build-tools Rev. 20

And here’s my code :

public function new () {		
	super ();		
	admob = new Admob();
	admob.addEventListener(AdmobEvent.INIT_OK, onAdmobInit);
	admob.addEventListener(AdmobEvent.INTERSTITIAL_CACHE_OK, onAdmobCache);
	admob.init();
}

private function onAdmobInit(e:AdmobEvent):Void{
	admob.cacheInterstitial(ADMOB_UNIT_ID);
}

private function onAdmobCache(e:AdmobEvent):Void {
	admob.showInterstitial();
}

Everything looks good, I don’t know, give me your empty project, I’ll check.

Hi @pozirk,

Silly me, I just found out that there is nothing wrong with the code or the extension, it’s just the admob unit id. I used the banner ads id to display interstitial ads, it seems that I must create another ad unit id to display interstitial. It works like a charm now. :grin:

Sorry for the trouble, and thanks for your reply.

Hi all!
When i’m trying to build app with this extension lime throws exeptions in cmd:

C:/HaxeToolkit/haxe/lib/admob-openfl/0,0,3/com/pozirk/ads/Admob.hx:76: characters 18-53 : Class<lime.utils.JNI> has no field createStaticMethod

What i’m doing wrong?

Read comments here:
http://www.openfl.org/blog/2015/03/20/here-comes-the-first-openfl-3-beta/

Thank you. Lets wait for final release)