AdMob - show("banner") doesn't work after exit and restart app

Hi @vlads how are you ?

I’m using the admob plug-in to show simple banner’s im my app and unity ad’s to show interstitial and rewarded videos. I created a module to simplify the processo to show banners and in my test’s i’m noted that some times the banner doesn’t show, after many debug’s I’m think there’s a BUG in AdMob module when you exit and restart a app. The show(“banner”) doesn’t work anymore, in my debug’s after the restart the admob module not call the listener.

I put a example that cam be used to test the BUG.

admob.zip (6.2 KB)

I’m not completed all my test’s yet, but I’m thinking that the unity ad plug-in has the same bug, because the placementId doesn’t appear in a debug that I setted in the listener.

Can you give a look in the problem please.

Thanks :slight_smile:

1 Like

Hello
Bug is still actual?

Hi @burdin.a.d

Yes, the bug is recent, I tested it on 4 different devices and the problem always occurs. I managed to make the banner appear again if I kill the application on my cell phone.

  1. When you say ‘exit and restart’, do you mean:

A. suspend and resume?
-OR-

B. Completely kill/quit app and then cold-start it?

  1. Sample looks like the one I provided in May 2020. The listener has a rudimentary dump mechanism in the adListener. Please provide us with logs from each of the three runs showing what is dumped. As an attachment would be best.

  2. Are you getting an init each time you start the app/demo?

  3. Have you tried calling isLoaded() after init?
    https://docs.coronalabs.com/plugin/admob/isLoaded.html

It may be that admob knows there is a cached ad and doesn’t load a new one.

I @roaminggamer, thanks for the help :slight_smile:

Let’s answer your questions :

B)
If I quit app an try start the app again, the banner doesn’t show
If I force kill the app an try start the app again, the banner work

  1. It’s a example that someone put in the forum with this same problem (log below)

  2. yeap, I call init every time that app start

  3. yes, I created a timer.performWithDelay and call a function tho show the banner :

timer.performWithDelay( 2000, showBanner, 3)

local function showBanner()
print("############### Trying show banner #############")
if admob.isLoaded(“banner”) then
print("############### Show banner #############")
admob.show( “banner” )
end
end

Blockquote

  1. APP first run
    ===========================================

---------- Device Log Starts ----------
Jan 05 13:57:16.567 SM-G950F: wai
Jan 05 13:57:23.402 SM-G950F: Platform: SM-G950F / ARM64 / 9 / Mali-G71 / OpenG
2020.3635 / português | BR | pt_BR | pt
Jan 05 13:57:23.427 SM-G950F: ERROR: admob.is
Jan 05 13:57:23.427
Jan 05 13:57:23.452 Loaded(adType [, options]), admob.init() must be called before calling other API functions
Jan 05 13:57:23.452 SM-G950F: WARNING: admob.init(listener, options), AppId is ignored and should be in build.settings
Jan 05 13:57:23.453
Jan 05 13:57:25.087 SM-G950F: plugin
Jan 05 13:57:25.087 .admob: 1.2.6 (SDK: 0)
Jan 05 13:57:25.121 SM-G950F:
Jan 05 13:57:25.122 phase init
SM-G950F: provider admob
SM-G950F: name adsRequest
SM-G950F: isError false
SM-G950F: ---------------------------
SM-G950F: ============= INIT =====================
Jan 05 13:57:25.343 SM-G950F: wait for provider
Jan 05 13:57:27.797 SM-G950F: type
Jan 05 13:57:27.798 banner
SM-G950F: name adsRequest
SM-G950F: phase loaded
SM-G950F: provider admob
SM-G950F: data {“adUnitId”:“ca-app-pub-XXXX106474799480”}
SM-G950F: isError false
SM-G950F: ---------------------------
Jan 05 13:57:27.851 SM-G950F: type ban
Jan 05 13:57:27.852 ner
SM-G950F: name adsRequest
SM-G950F: phase displayed
SM-G950F: provider admob
SM-G950F: data {“adUnitId”:“ca-app-pub-XXXX106474799480”}
SM-G950F: isError false
SM-G950F: ---------------------------
Jan 05 13:57:36.283 SM-G950F: TouchDown inte
Jan 05 13:57:36.283 nt received, starting ActiveLaunch

  1. After exit the app and try to run again
    ===========================================
    Jan 05 13:57:36.629 SM-G950F: Platform: SM-G950F / ARM64 / 9 / Mali-G71 / OpenGL ES 3.2 v1.r16p0-01rel0.###other-sha0123456789ABCDEF0### / 2020.3635 / português | BR | pt_BR | pt
    Jan 05 13:57:36.657 SM-G950F: ERROR: admob
    Jan 05 13:57:36.657
    Jan 05 13:57:36.659 .isLoaded(adType [, options]), admob.init() must be called before calling other API functions
    Jan 05 13:57:36.659 SM-G950F: WARNING: admob.init(listener, options), AppId is ignored and should be in build.settings
    Jan 05 13:57:36.659

Observation:

  1. How can you can see, when I tried to run the app in the second time, the event.phase == “init” doesn’t is called in the listener and the .isLoaded doesn’t work to check if there’s a cached banner, when I tried to call this I got “ERROR: admob.isLoaded(adType [, options]), You must wait for the ‘init’ event before calling other API functions”

  2. When I force the app quit, the app can show the banner. Maybe there’s a cache, but I can’t check if the cache exist and If I try to force the admob.init() I has errors inform me that I can’t use admob.init()

  1. I am unclear on the status of the Admob plugin. I thought there was an issue recently and just assumed it was working again when I saw your post.

@anyone - Anyone reading who knows, please post current status.

  1. Please post back the exact version of Solar2D you are using so I can try the same version.

  2. You are right. Your init call is not working and that needs to work before you can do any other steps.

  3. I forgot to ask, but you’re using an Android device(s) right?

  4. I’ll give this a try tonight (on a Pixel 3a XL) and post back when I have results of my own.

Sorry for the long delay, but my day job comes first.

Cheers,
Ed (aka The Roaming Gamer)

@roaminggamer : New answers :slight_smile:

  1. Please post back the exact version of Solar2D you are using so I can try the same version.
    Version 2020.3635 (2020.12.21)
  1. You are right. Your init call is not working and that needs to work before you can do any other steps.
    I suspect that exist a cache from admob, but I can’t check and I can’t force the initialize process
  1. I forgot to ask, but you’re using an Android device(s) right?
    Yeap I’m using a galaxy S8 for the test
  1. I’ll give this a try tonight (on a Pixel 3a XL) and post back when I have results of my own.
    OK :slight_smile:

Sorry for the long delay, but my day job comes first.
Do not worry … Thanks again for your attention. I may be doing something wrong, but I followed the existing solar2d documentation and as I realized that there was an error I decided to report on the forum to help other people.

I’m behind on this, but I will give it a try and see what I find.

The AdMob plugin had seen its fair share of issues for a long time, however, I haven’t experienced any issues with AdMob since its latest update.

Well dang. I worked on a test app only to find out my machine is goofed up and I can’t build it right now.

So, I’m attaching it in the hopes it will help you.

It lets you break up the steps and do them interactively, while giving some visual and log feedback.

You’ll need to edit main.lua and build.settings to get it to work. (add your ids)

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2021/01/admob.zip

Warning you may need or want to tweak this more to get more feedback.

I hope this helps and doesn’t detract. I’d do more testing, but I’m just not up to debugging my machine tonight.

Thanks and good luck.

Hi @vlads ! Can you give a little help in this problem please.

@roaminggamer

All right? I saw your code and understood what you intended to do.

I was already working on something like that and got the time to code what was missing yesterday. In the program you will be able to see what happens with each step of the Admob flow:

  • Initialize
  • Load
  • Show
  • Hide
  • Error

How to test:

  1. Adjust build.setting with APPLICATION_ID and main.lua with Ad Unit ID and build for android

  2. The first time the application is run, all Admob statuses that appear on the screen should work correctly.

  3. Close the application and open it again. The status will not work, it seems that there is some kind of cache when the program is executed again and the initialize process is not executed even though the admob module is being loaded.

  4. If you force to kill the application from the phone’s memory, the banners should appear normally.

Maybe I’m doing something wrong, but I followed the existing documentation.

Another point, the example of the Admob module, which exists in the repository is out of date with the documentation.

Here’s the example to test
admobDebug.zip (72.1 KB)

Thank’s
Lugato

@vlads can you close the issue please:

To solve the problem :
I’m passing a erroneous AD_UNT_ID when using admob.load( “banner”, tableParameters):

NOTE:
When I tried to use ADMOB with iOS, you got error and the banner doesn’t show if you pass the testMode parameter

Android :
tableParameters = {adUnitId=AD_UNT_ID, testMode=true, childSafe=true, designedForFamilies=true, hasUserConsent=false}
admob.load( “banner”, tableParameters)

iOS :
tableParameters = {adUnitId=AD_UNT_ID, childSafe=true, designedForFamilies=true, hasUserConsent=false}
admob.load( “banner”, tableParameters)