+5 votes

At the end of this article, link to the game can be seen.
I just want to share my experience implementing real ads in game.

Tested on:
Godot Engine 3.1.1.stable.official

Used library:

Code used for showing both banner and interstitial ads:
Below the code is explanation.
Make sure you have placed this script in AutoLoad section.

extends Node
var admob = null
var isReal = true
var isTop = true

var adBannerId = "" # [Replace with your Ad Unit ID and delete this message.]
var adInterstitialId = "" # [Replace with your Ad Unit ID and delete this message.]

var is_next_interstitial = false

func _ready():

func _init_ads():

        admob = Engine.get_singleton("AdMob")
        var res = admob.init(isReal, get_instance_id())

        admob.loadBanner(adBannerId, isTop)

        game.connect("ad_interstitial_should_be", self, "_on_ad_interstitial_should_be")


func _on_interstitial_close():
    is_next_interstitial = false

func _on_interstitial_loaded():
    is_next_interstitial = true

func _on_interstitial_not_loaded():
    is_next_interstitial = false

func _on_ad_interstitial_should_be(game):
    if is_next_interstitial:


Make sure you have set your ad ids to variables adBannerId and adInterstitialId.

Install admob module like it described in the link for admob module (README.md)
1. When script is loaded up, we postponed calling function _init_ads through call_deferred, because
2. In _init_ads function, we are getting admob module and init it with value returned from get_instance_id ( that's because you have to connect your application to module native code, so when any action have happen in the background, appropriate function within your application get called, example:
_on_interstitial_close, _on_interstitial_not_loaded....
function list can be seen on link for admob module in README.md
3. Next thing you want to resize view for banner, so it can be seen on screen, by calling admob.resize()
4. Next thing is loading banner and showing up and also to loadInterstitial
5. Next thing is crucial for logic of showing interstitial ad:
Note first that we had connect this script to signal from game script named: ad_interstitial_should_be
we have implemented it in way that after every fifth round interstitial ad have showed up in this manner: When player end game (gameover), function in script gamecalled game_over is called. If counter says that five round have passed, we do

call_deferred("emit_signal", "ad_interstitial_should_be", self)
6. So on _on_ad_interstitial_should_be, we check if interstitial ad have loaded up by checking variable is_next_interstitial, and if it is, we show interstitial ad.
7. Now special functions for interstitial ad:
_on_interstitial_close - when user close interstitial ad variable is_next_interstitial is set to false
_on_interstitial_loaded - when interstitial ad have loaded up variable is_next_interstitial is set to true
_on_interstitial_not_loaded - vice versa

And that's it.

First you make sure that test ads are loading up, by setting variable isReal to false
Now when we have tested game with real ads, we got some errors.
we got popular error ERROR_CODE_NO_FILL. You can see here about that error

It says

The ad request was successful, but no ad was returned due to lack of ad inventory.

What we have tried, we don't know if it is right thing to do, but we think it doesn't anything harm (don't take me for word):
Admob module uses 'com.google.android.gms:play-services-ads:16.0.0' sdk,
and we have read that this sdk doesn't require APPLICATION_ID
Link: https://developers.google.com/admob/android/quick-start

But we have just in case put in manifest file this piece of code (code copied from link above):


we don't know, but now when the game is published real ads works.
Your APPLICATION_ID gives you AdMob portal/dashboard/service, when you logged in.

When you put this code in your AndroidManifest file, you have to recompile everything.
Link for recompiling:

Also when you debugging the admob module, like it says in the link of the module, it is helpful command to do: adb logcat -s godot

Game on the Google Play:

in Engine by (28 points)

Hi, my name is Carlos. I'm new with this programming language. I have some doubts about the implementation of admod. I could communicate with you.

I wait your answer

2 Answers

+2 votes
Best answer

Tested on:
Godot Engine 3.1.1.stable.official

With admob module:

by (28 points)
+1 vote

You can use precompiled modules for Applovin-Max and for Tapdaq mediation solutions. They allow you use several ad networks like AdMob or Facebook audience network.
All binary modules can be installed from NativeLib repository. NativeLib addon you can find in AssetLib.
More info at:

by (214 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.