Admob V2 - can't get it to show ad

Hi


Update 

A friend of mine tried playing the game, and he said that the ads showed after a minute or so… Strange? 


I’ve searched around quite a bit but cannot find any solutions to my problem. Searching around helped me make the actual app, but now I have to ask for someones help :slight_smile: I trying to implement admob to my app.

If i show the ad like this: 

ads.show( "banner", { x=contentCenterX, y=0, appId=bannerAppId, testMode = true } )

I get an black ad-bacground (but no ad). If I remove the “testmode = true” part I don’t even get the blak ad-less background.

My build.settings are like this, including it all since I might overlook something.

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", } }, plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, }, iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- example scheme for facebook "coronasdkapp", -- example second scheme } } } --]] } }, -- Android permissions android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", }, } }

And in my game.lua file:

ads = require( "ads" ) appId = "ca-app-pub-numbers (changed them here)" if ( system.getInfo( "platformName" ) == "Android" ) then appId = "ca-app-pub-numbers (changed them here)" end adProvider = "admob" function adListener( event ) msg = event.response -- just a quick debug message to check what response we got from the library print("Message received from the ads library: ", msg) if event.isError then print( "Error, no ad received", msg ) else print( "Ah ha! Got one!" ) end end ads.init( adProvider, appId, adListener )

The code above is placed before the:

"function scene:create( event )

    local sceneGroup = self.view" code.

And after:

ads.show( "banner", { x=contentCenterX, y=0, appId=bannerAppId, testMode = true } )

I haven’t linked to the app yet in admobs website, because I can’t find the app in Google Play store yet from admob. (I find it on play.google.com)

Do it need to be linked for ads to work? If so, searching the web didn’t tell me at all, and it would be a crucial information.

Any help is appreciated very much :slight_smile:

By the way: The app is located here if its to any help: https://play.google.com/store/apps/details?id=com.gmail.fagerland.christian.Distracted_Driver

What messages are appearing in your device’s console log?  If you don’t now how to read it, please read:  http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Rob

Hi.

I did the debug now. My game typical lasts for 1-3 minutes before user press “try again” then you go from “game.lua” to “reload.lua”

Seems like this might have something to do with it. I don’t know if i have to “flush” the ads.init() somehow. would like the ad to stay put even if i restart the game.

The reload.lua does removes the game.lua.

--------- beginning of /dev/log/system --------- beginning of /dev/log/main V/Corona (22229): \> Class.forName: network.LuaLoader V/Corona (22229): \< Class.forName: network.LuaLoader V/Corona (22229): Loading via reflection: network.LuaLoader I/Corona (22229): Platform: D6503 / ARM Neon / 4.4.2 / Adreno (TM) 330 / OpenGL ES 3.0 V@66.0 AU@ (CL@) / 2014.2407 V/Corona (22229): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22229): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22229): Loading via reflection: CoronaProvider.licensing.google.LuaLo ader V/Corona (22229): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22229): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22229): Loading via reflection: CoronaProvider.ads.admob.LuaLoader I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one! I/Corona (22229): now in reload scene for a moment... I/Corona (22229): WARNING: ads.init() was already called for admob. I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one! I/Corona (22229): now in reload scene for a moment... I/Corona (22229): WARNING: ads.init() was already called for admob. I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one!

Where is your ads.init() call?  It should be in your main.lua, not in each scene.  It just needs called once per run.  Where are your ad.show() and ad.hide() calls?

Rob

My ads.init() was in game.lua file. placed it above composer calls. (before any scene were created)

I’ve now moved it to main.lua.

My ad.show were, and still are in game.lua and I’ve placed after the 

function scene:create( event ) local sceneGroup = self.view

Well, after a lot of other code that is (a lot of objects like images and texts, didn’t know if I have to layer the ad or if its always on top)

I don’t have any ad.hide because I want the ad to be uninterrupted after beeing loaded in game.lua. 

Game.lua goes to reload.lua for 100ms. Do I have to use ads.hide?

Checked the debug again:

I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! V/Corona (22874): \> Class.forName: network.LuaLoader V/Corona (22874): \< Class.forName: network.LuaLoader V/Corona (22874): Loading via reflection: network.LuaLoader I/Corona (22874): Platform: D6503 / ARM Neon / 4.4.2 / Adreno (TM) 330 / OpenGL ES 3.0 V@66.0 AU@ (CL@) / 2014.2407 V/Corona (22874): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22874): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22874): Loading via reflection: CoronaProvider.licensing.google.LuaLo ader V/Corona (22874): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22874): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22874): Loading via reflection: CoronaProvider.ads.admob.LuaLoader I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! I/Corona (22874): now in reload scene for a moment... I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! I/Corona (22874): now in reload scene for a moment... I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one!

Maby I have to put ads.show() before the scene creation. Gonna try that now… reporting back.

— 

Tried that, same result. Gets an “Ah ha! Got one!” after each reload. 

Reload.lua are removing the game.lua each time the user press “try again”


Thanks!

I would put your ads.show() in your scene:show() call inside the “did” phase, not scene:create().  You don’t want to call that until the scene is completely on the scene, though in theory the ads are not part of the scene and sit above the scene and any scene management should not affect them.

Can you post your adListener code?

ads = require( "ads" ) appId = "ca-app-pub-MyNymbers" \<-- removed these when pasted the code if ( system.getInfo( "platformName" ) == "Android" ) then appId = "ca-app-pub-MyNumbers" end adProvider = "admob" function adListener( event ) msg = event.response -- just a quick debug message to check what response we got from the library print("Message received from the ads library: ", msg) if event.isError then print( "Error, no ad received", msg ) else print( "Ah ha! Got one!" ) end end ads.init( adProvider, appId, adListener )

This code is now in top of Main.lua. No code at all is above it. 

I just did a test using my ProviderID’s… the only thing I added was an ad.show(“banner”) at the bottom.

ads = require( "ads" ) appId = "ca-app-pub-xxxxxxxx/xxxxxxx" if ( system.getInfo( "platformName" ) == "Android" ) then &nbsp;&nbsp;&nbsp; appId = "ca-app-pub-yyyyyyyyyyy/yyyyyy" end &nbsp;&nbsp;&nbsp; &nbsp; adProvider = "admob" function adListener( event ) &nbsp;&nbsp;&nbsp; msg = event.response &nbsp;&nbsp;&nbsp; -- just a quick debug message to check what response we got from the library &nbsp;&nbsp;&nbsp; print("Message received from the ads library: ", msg) &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; if event.isError then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print( "Error, no ad received", msg ) &nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print( "Ah ha! Got one!" ) &nbsp;&nbsp;&nbsp; end end &nbsp;&nbsp;&nbsp; &nbsp; ads.init( adProvider, appId, adListener ) ads.show("banner")

The ad showed at the top of the page as expected.   What does your ads.show()  code look like?

Tried that to, but didn’t seem to work. 

My ads.show code is:

ads.show( "banner", { x=contentCenterX, y=0, appId=bannerAppId })

A very few times the ads has appeared. tried on several devices. More often I see a black ad background but no ad.

Where do you define a variable “bannerAppId” that has the AdMob provider ID for your banner?

I don’t know how I oversaw that. I removed it now since it then fetch the info from ads.init(). But still no ads. 

I’ve just read about fillrate. Some articles mention a fillrate of about 30%. i.e that only in 30% ad requests returns in an actual ad.

In addition, I read that new apps gets an even lower fillrate until more users use the app and thereby requests ads. (Then Admob knows its not just the developer testing the app that gets ads)

If so, wouldn’t this be crucial information to take into account when debugging ads? Should be a big note in the Coronas tutorial?

UPDATE:

Didn’t think this mattered: My game is in landscape. I tried and chance to portrait and then I saw the ads. 

So its a positioning thing then I guess :slight_smile:

UPDATE: Case closed

That’s it. I changed the positioning to: 

 ads.show( "banner", { x=display.screenOriginX / 2, y=display.screenOriginY, appID = bannerID})

and it just appears like a charm :slight_smile:

By the way: The app is located here if its to any help: https://play.google.com/store/apps/details?id=com.gmail.fagerland.christian.Distracted_Driver

What messages are appearing in your device’s console log?  If you don’t now how to read it, please read:  http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Rob

Hi.

I did the debug now. My game typical lasts for 1-3 minutes before user press “try again” then you go from “game.lua” to “reload.lua”

Seems like this might have something to do with it. I don’t know if i have to “flush” the ads.init() somehow. would like the ad to stay put even if i restart the game.

The reload.lua does removes the game.lua.

--------- beginning of /dev/log/system --------- beginning of /dev/log/main V/Corona (22229): \> Class.forName: network.LuaLoader V/Corona (22229): \< Class.forName: network.LuaLoader V/Corona (22229): Loading via reflection: network.LuaLoader I/Corona (22229): Platform: D6503 / ARM Neon / 4.4.2 / Adreno (TM) 330 / OpenGL ES 3.0 V@66.0 AU@ (CL@) / 2014.2407 V/Corona (22229): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22229): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22229): Loading via reflection: CoronaProvider.licensing.google.LuaLo ader V/Corona (22229): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22229): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22229): Loading via reflection: CoronaProvider.ads.admob.LuaLoader I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one! I/Corona (22229): now in reload scene for a moment... I/Corona (22229): WARNING: ads.init() was already called for admob. I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one! I/Corona (22229): now in reload scene for a moment... I/Corona (22229): WARNING: ads.init() was already called for admob. I/Corona (22229): Message received from the ads library: I/Corona (22229): Ah ha! Got one!

Where is your ads.init() call?  It should be in your main.lua, not in each scene.  It just needs called once per run.  Where are your ad.show() and ad.hide() calls?

Rob

My ads.init() was in game.lua file. placed it above composer calls. (before any scene were created)

I’ve now moved it to main.lua.

My ad.show were, and still are in game.lua and I’ve placed after the 

function scene:create( event ) local sceneGroup = self.view

Well, after a lot of other code that is (a lot of objects like images and texts, didn’t know if I have to layer the ad or if its always on top)

I don’t have any ad.hide because I want the ad to be uninterrupted after beeing loaded in game.lua. 

Game.lua goes to reload.lua for 100ms. Do I have to use ads.hide?

Checked the debug again:

I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! V/Corona (22874): \> Class.forName: network.LuaLoader V/Corona (22874): \< Class.forName: network.LuaLoader V/Corona (22874): Loading via reflection: network.LuaLoader I/Corona (22874): Platform: D6503 / ARM Neon / 4.4.2 / Adreno (TM) 330 / OpenGL ES 3.0 V@66.0 AU@ (CL@) / 2014.2407 V/Corona (22874): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22874): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (22874): Loading via reflection: CoronaProvider.licensing.google.LuaLo ader V/Corona (22874): \> Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22874): \< Class.forName: CoronaProvider.ads.admob.LuaLoader V/Corona (22874): Loading via reflection: CoronaProvider.ads.admob.LuaLoader I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! I/Corona (22874): now in reload scene for a moment... I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one! I/Corona (22874): now in reload scene for a moment... I/Corona (22874): Message received from the ads library: I/Corona (22874): Ah ha! Got one!

Maby I have to put ads.show() before the scene creation. Gonna try that now… reporting back.

— 

Tried that, same result. Gets an “Ah ha! Got one!” after each reload. 

Reload.lua are removing the game.lua each time the user press “try again”


Thanks!

I would put your ads.show() in your scene:show() call inside the “did” phase, not scene:create().  You don’t want to call that until the scene is completely on the scene, though in theory the ads are not part of the scene and sit above the scene and any scene management should not affect them.

Can you post your adListener code?

ads = require( "ads" ) appId = "ca-app-pub-MyNymbers" \<-- removed these when pasted the code if ( system.getInfo( "platformName" ) == "Android" ) then appId = "ca-app-pub-MyNumbers" end adProvider = "admob" function adListener( event ) msg = event.response -- just a quick debug message to check what response we got from the library print("Message received from the ads library: ", msg) if event.isError then print( "Error, no ad received", msg ) else print( "Ah ha! Got one!" ) end end ads.init( adProvider, appId, adListener )

This code is now in top of Main.lua. No code at all is above it.