AdMob ads not showing up (SOLVED)

Hello everyone!
So I am trying to implement ads in my game using https://github.com/Lerg/extension-admob/ extension, but the ads doesn’t appear on the screen.

Dependencies : http://prntscr.com/q9gyuy
Script file : http://prntscr.com/q9h0fv

When I run my game I get this : INFO:ADMOB: init but ads doesn’t show on the screen.
Also I set my Android App Id in the game project file.

Thanks for helping!

Hello nEz,

afaik ads shows up only running the bundled apk on mobile device.

I bundled my game, transfered apk to my device,installed it, but the ads still doesn’t appear.

You can check event.is_error and event.error_code inside the listener and print additional info for debugging

2 Likes

I added
print(‘admob event is error’, event.is_error)
print(‘admob error code’, event.error_code)
print(‘admob error code’, event.error_message)
but there are no errors appearing on the debug console.

You need to check logcat from the mobile device.
You can use android device monitor (from android sdk)

1 Like

So I tried debugging via Android Studio.
logcat : http://prntscr.com/qadi8x

Try filtering with defold keyword to find what are you printing in the script.

http://prntscr.com/qafo8m Results.

The script errors are probably unrelated but you should fix those because they might interfere with the code where you are showing the ad.

And please share copy pasted code/logs instead of screenshots.

Also, do I need to do Google AdMob ad unit implementation work or does the extensions do the work? Because I haven’t done it, maybe this is the problem?

I haven’t tried the extension myself, but you need an admin id from Google, you need to initialize the extension, you need to load/preload an ad and then you need to show the as. Are you doing all this?

You can look at the example that comes with the extension if you are uncertain of how it should work.

I’m using Lerg Admob extension successfully :+1:

You have only to configure it properly

Double check:

game.project
[admob] section must be correct spelled

Add this lines into listener to check admob errors

Comment out app_id within init

This is an example of correct initialization traced with logcat on mobile device (filter with tag:defold)

This is an example having problems during initialization.
I’ve intentionally broken banner ads id to get an error

A common issues is getting error code 3.
I’m sure getting this error in the beginning.
It disappeared after testing the application on the mobile device several times, and the banners started to appear

Hope this helps.

6 Likes

The problem is, that I don’t get any errors/information related to admob when I debug.

Maybe script with admob code is not attached to any game object or gui.

It is attached :confused:
The only message I get from admob is init.

Try adding enable debug

It doesn’t give any more information :confused:
What I noticed is that on Defold console I get admob: init, but on Android Device monitor I don’t get this message.

Hey man!

It was a rebus :sweat_smile:

Your script has something odd:

admob.init() is not inside the init function, it is at global level.

I think the listener could not be found @ runtime on mobile device because is out of scope.

Sorry for the awful arrow, try moving the init call there!!

3 Likes

OMG! THANK YOU SO MUCH! BANNER APPEARED!! I LOVE YOU :smiley:

I made the script file using this example : https://docs.spiralcodestudio.com/extension/admob/init/
And as you can see admob.init function is at the global level.

1 Like