Admob plugin not loading test ads

Corona version: 3184

Admob plugin version: 1.2.2

Hello,

I am having a problem getting banner ads to display. The app will init the Admob plugin (set to testMode = true) and in the adListener monitor for event.phase == “init”. Once “init” has been detected, the code will then proceed to attempt to load an ad. This is where the mystery lies. Once admob attempts to load the ad,

event.phase is “failed”,

event.response is “loadFailed”

event.data is {“errorMsg”:“No Ads Available”,“errorCode”:3,“adUnitId”:“ca-app-pub-*****”}

[lua]

main.lua

local admob = require( “admob” )

. . .

admob.ads.init( admob.adListener, { appId = admob.AppID, testMode = true } )

admob.lua

local Z = {}

Z.ads = require( “plugin.admob” )

Z.bannerAdUnitID = “ca-app-pub-*****” – iOS by default

Z.interstitialAdUnitID = “ca-app-pub-*****” – iOS by default

Z.AppID = “ca-app-pub-*****” – iOS by default

if ( system.getInfo( “platformName” ) == “Android” ) then

    – AdUnitID

    Z.bannerAdUnitID = “ca-app-pub-*****”

    Z.interstitialAdUnitID = “ca-app-pub-*****”

    Z.AppID = “ca-app-pub-*****”

end

Z.adProvider = “admob”

– function displays a banner ad

local function showBanner()

     Z.ads.show( “banner”, { y=“bottom” } )

end – end showBanner()

Z.showBanner = showBanner

local function adListener( event )

    print(“Ad listener was called!”)

    print("Phase: " … event.phase)

    if (event.phase == “displayed” and event.type == “interstitial”) then

    showBanner()

    elseif(event.phase == “refreshed”) then

    print(“Refresh ad”)

    elseif(event.phase == “loaded”) then

    print(“If Banner Ad is loaded, so show it!”)

    print("Type: " … event.type)

    – show the banner

    if(event.type == “banner”) then

    showBanner()

    end

    elseif(event.phase == “init”) then

    print(“Now load the banner & interstitial”)

    – load the banner here

    Z.ads.load( “banner”, { adUnitId = Z.bannerAdUnitID } )

    elseif( event.phase == “failed”) then

    print(“Event failed…data to follow”)

    print(event.response)

    print(event.data)

    elseif( event.iserror ) then

    print(“We should try to get a different ad!”)

    end

end

Z.adListener = adListener

– function hides the banner and shows an Interstitial

local function showInterstitial( testOrProd )

    – hide the banner

    Z.ads.hide()

    Z.ads.show(“interstitial”)

end – end showInterstitial()

Z.showInterstitial = showInterstitial

return Z

[/lua]

I saw this post  which is similar only he is in Malaysia (I am in US currently). Additionally there was this post where a Corona employee posted a link to a sample project. I tried the sample project and it does work with my credentials (meaning that it does load an ad with my appId and adUnitId) however that app is structured differently in that it does not load the ad automatically, only when you click the Load button. I sense there is something obvious that I am missing but can’t seem to connect with. Any suggestions are appreciated!

Thank you,

Ed

2 updates:

I replaced line 48 with this:

timer.performWithDelay ( 5000, function() Z.ads.load( "banner", { adUnitId = Z.bannerAdUnitID } )  end )

and it worked…sort of. 

The test ad loaded (although it looked like a real ad…hhmmm) and refreshed 3 times before it went back to the error listed previously (“No Ads Available”). It appears as though the account is getting rate limited, although that would be odd since I am using the default refresh time as defined by Google. Another consideration was that maybe I was NOT in test mode somehow, but in the terminal output this line appears:

plugin.admob: Test mode active for device ‘F80335FFC187C2552B8382EB2C48B994’

According to this page there are 2 ways to test ads with Admob. They are either to use the sample Ad Units listed on the page or to configure the device as a test device while you are testing (which I assume is what the Corona Admob Plugin does). If done correctly, the test ad displayed should have an overlay on the ad that reads ‘Test Ad’. When I was able to get the ad to display using the steps in Update 1 above, my ads did NOT display the overlay.

Anyway for anyone looking at this, those are the 2 updates. I am going to try the sample ad units next and will report back.

Thank you to anyone following this.

Ed

Another update:

When I use the test Ad Units listed on the Admob page, the app successfully loads a test ad and refreshes away! The test ads are pretty easy to distinguish from live ads: They have a black background and say “AdMob Test Smart Banner”. So at this point it would appear that testMode is not currently working in the plugin or there is something I did wrong to set testMode. Either way, hopefully this helps someone else!

Thank you,

Ed

For others that come along later, these are the test Ad Units on the Admob link above:

Ad format                 Sample ad unit ID

Banner                     ca-app-pub-3940256099942544/6300978111

Interstitial                 ca-app-pub-3940256099942544/1033173712

Rewarded Video      ca-app-pub-3940256099942544/5224354917

Native Advanced     ca-app-pub-3940256099942544/2247696110

I don’t see anything immediately wrong with your code. There shouldn’t be timing issues other than to make sure plugin has time to complete initialization before showing ads.

I’ll ask an engineer to look into this thread. But you might want to try and modify the sample app to try and auto load the ad after you get the initialization event.

Rob

Well, that is interesting. At first, I’ve got a couple thoughts about it, but all my attempts on represent this issue failed, sadly.

If you can see this log message plugin.admob: Test mode active for device ‘…’, then test mode is active for sure and the init went fine. Also, I’ve checked all available init parameters combinations and for me test mode always working as expected (banners with “Test ad” overlay and stuff, “AdMob Test Smart Banner” should be specific for test ad units). Also, it would be nice to see a full log.
 

Here’s what we can do to speed things up: make a bug submit at https://portal.coronalabs.com/bug-submission and make sure to include a small sample to reproduce that issue. I’ll check your code and also will make some internal build for debug - then I can give you an insight about what exactly is wrong with your code and we can fix it straight away together.

Btw, have you looked at this mentioned thread https://forums.coronalabs.com/topic/71881-admob-plugin-test-mode-question/ more closely? It seems that admob is working with banners in some specific way on Admob’s side. But I can’t say what’s wrong with your particular case without a sample to reproduce an issue.

Hi karpovpw, thank you for the response!

I was having some troubles earlier with getting a build done so sorry for the slow response.

The link you posted I had read before I posted but it did not seem to apply.

I trimmed the code down to the bare minimum and am still receiving some odd behavior with testMode=true. With the test adUnits provided by Google I get the Smart Banner but when I use my adUnits I am still having issues. Here is the output from the terminal:

03-19 19:38:11.981 12061 12083 V Corona : \> Class.forName: network.LuaLoader 03-19 19:38:11.982 12061 12083 V Corona : \< Class.forName: network.LuaLoader 03-19 19:38:11.982 12061 12083 V Corona : Loading via reflection: network.LuaLoader 03-19 19:38:11.994 12061 12083 I Corona : Platform: Nexus 7 / ARM Neon / 6.0.1 / Adreno (TM) 320 / OpenGL ES 3.0 V@127.0 AU@ (GIT@I96aee987eb) / 2017.3184 / E nglish | US | en\_US | en 03-19 19:38:12.025 12061 12083 V Corona : \> Class.forName: shared.google.play.services.base.LuaLoader 03-19 19:38:12.025 12061 12083 V Corona : \< Class.forName: shared.google.play.services.base.LuaLoader 03-19 19:38:12.026 12061 12083 V Corona : Loading via reflection: shared.google.play.services.base.LuaLoader 03-19 19:38:12.039 12061 12083 V Corona : \> Class.forName: \_CoronaSetup.LuaLoader 03-19 19:38:12.050 12061 12083 V Corona : \> Class.forName: plugin.admob.LuaLoader 03-19 19:38:12.052 12061 12083 V Corona : \< Class.forName: plugin.admob.LuaLoader 03-19 19:38:12.052 12061 12083 V Corona : Loading via reflection: plugin.admob.LuaLoader 03-19 19:38:12.053 12061 12083 I Corona : Time to INIT ads... 03-19 19:38:12.055 12061 12083 I Corona : plugin.admob: Generated AdMob Test ID 'F80335FFC187C2552B8382EB2C48B994' 03-19 19:38:12.080 12061 12083 V Corona : \> Class.forName: CoronaProvider.licensing.google.LuaLoader 03-19 19:38:12.080 12061 12083 V Corona : \< Class.forName: CoronaProvider.licensing.google.LuaLoader 03-19 19:38:12.093 12061 12083 V Corona : Loading via reflection: CoronaProvider.licensing.google.LuaLoader 03-19 19:38:12.341 12061 12061 I Corona : plugin.admob: 1.2.2 (SDK: 11400000) 03-19 19:38:12.343 12061 12083 I Corona : Ad listener was called! 03-19 19:38:12.343 12061 12083 I Corona : Phase: init 03-19 19:38:12.343 12061 12083 I Corona : Now load the banner & interstitial 03-19 19:38:17.357 12061 12083 I Corona : plugin.admob: Test mode active for device 'F80335FFC187C2552B8382EB2C48B994' 03-19 19:38:20.385 12061 12083 I Corona : Ad listener was called! 03-19 19:38:20.385 12061 12083 I Corona : Phase: loaded 03-19 19:38:20.385 12061 12083 I Corona : Banner Ad is loaded, so show it! 03-19 19:38:20.385 12061 12083 I Corona : But this could mean that the interstitial is load, so which is it? 03-19 19:38:20.385 12061 12083 I Corona : Type: banner 03-19 19:38:20.450 12061 12083 I Corona : Ad listener was called! 03-19 19:38:20.450 12061 12083 I Corona : Phase: displayed 03-19 19:39:21.815 12061 12083 I Corona : Ad listener was called! 03-19 19:39:21.815 12061 12083 I Corona : Phase: refreshed 03-19 19:39:21.815 12061 12083 I Corona : Refresh ad 03-19 19:40:23.195 12061 12083 I Corona : Ad listener was called! 03-19 19:40:23.195 12061 12083 I Corona : Phase: refreshed 03-19 19:40:23.195 12061 12083 I Corona : Refresh ad 03-19 19:41:24.464 12061 12083 I Corona : Ad listener was called! 03-19 19:41:24.464 12061 12083 I Corona : Phase: refreshed 03-19 19:41:24.464 12061 12083 I Corona : Refresh ad 03-19 19:42:25.024 12061 12083 I Corona : Ad listener was called! 03-19 19:42:25.024 12061 12083 I Corona : Phase: failed 03-19 19:42:25.024 12061 12083 I Corona : Event failed....data to follow 03-19 19:42:25.024 12061 12083 I Corona : loadFailed

Ok, I submitted some test code a few minutes ago…did not receive a bug submission ID.

I am seeing your submission, thanks for that.

The solution will come up asap, I’ll post in the related threads when it’s done.

Well, here’s what we’ve investigated so far from a sample in your bug submission :

Both ios and android builds are working exactly as expected, showing test ads when testMode is active. I’ve double checked everything through internal debug - all parameters are received and sent to Admob correctly. Sadly, we can’t do anything here.

If you are getting these test ads inconsistently or having any other ads/fill issues with an Admob Corona plugin you should write a request to Admob’s support team, I’m sure they can help you eliminate all of them.

As I’ve said, it’s a pity, but we have no control over what is coming to us from Admob. Test mode working exactly as it should be, but how Admob will answer to us requesting a test ads is a complete mystery.

Btw, seems like android version of test ads do not come with a “Test Ad” overlay.

Dunno, what else I can help you with. Be sure to write back after you’ll solve issues with the help of Admob’s team, I think it can be useful to someone. I’ll be in touch, if you have any more questions or concerns - feel free to share them!

Thank you karpovpw for the help you have provided!

Here is what I receive when I use my appId and adUnitId and set Globals.release = ‘test’:

admob.png

Is it possible I can supply you with my appId and adUnitId that I use so you can see what I see?

Thank you!

Ed

Well, the thing is that I’ve already used your appId and adUnitId, they were included in the sample. I haven’t used our own credentials or something, just used your sample and went through steps to reproduce an issue.
 

Update: I am getting some feedback that users from other dev platforms (not Corona) are experiencing the same issue with Admob.

highly recommend you to write a letter to Admob - I am sure that they can help you with this ads/fill issue for test banners. As I’ve said, we can’t fix Admob’s ad filling, we just giving an access to their SDK with easier integration for Corona users, but how Admob is working out for users is completely under our radars.

Thank you karpovpw! I did not realize that I had left those ID’s in the code submitted as I had intended to remove them - oops!

I will reach out to Admob directly and post back my findings.

Ed

karpovpw,

Quick question - is it possible you could make the apk you built available to me so I could put it on my test device?

Thank you,

Ed

Sure, that’s a good idea.

Thank you karpovpw!

Is the apk tested above with the Admob test ad units? With that build I do receive the Smart Banner with the black background, not the test ad that you show in the images above.

Thank you,

Ed

As I’ve said,

Thank you for the response karpovpw.

If you took the code exactly as I sent it then that would imply there is a difference between the machine that you built the apk on and my machine. The code exactly as I sent to you does not show test ads unless I use the test ad units.

Here is my setup:

Windows 10 - 64 bit

Corona 2017.3184

JDK8u162 (64-bit)

I joined the Google Admob Mobile ads SDK group and they informed me that they don’t support questions on anything other than native Android and iOS apps as well as Unity and Cocos2d.

A quick summary of what I have tried:

Built on Windows 10 - 3184

Built on Mac OS 10.12.6 with 3184 & 3241

Built on Mac OS 10.13.3 with 3184

In all cases JDK8u162 (64-bit) was used.

Conclusion so far: Since the only change I have made to the code since I sent it in as a bug report is add 4 print statements and the code was compiled just fine by you, perhaps there is an issue with my account on the plugin/build server? If there was a problem on the Admob side of this then you should have received the same results as I did, but you did not. The primary differences are the account you used to do the build and the test device you used (and perhaps access to different build process internally?).

Test devices I have used:

Nexus 7 2013 Android 6.0.1

Nexus 9 Android 7.1.1

Nexus 6 Android 7.0

Look forward to your thoughts on this dilemma.

Thank you,

Ed

Hi karpovpw,

I just looked in the zip folder of the code I submitted for the Bug Report. The adUnit id’s that are in there are the Admob test ad unit id, not mine! So the code I submitted to you does not have my id’s.

Would you like to try to build again with my info?

Thank you,

Ed