Quick Tutorial: How to Use AdMob on Godot Engine
Autor: Shin-NiL | Publicado: 2016-05-09T09:35:00-03:00

As this seems to be a recurring topic, especially among beginners, I decided to write a tutorial on how to integrate AdMob on your Godot application, just as I did before with Appodeal.
Step 1Download and compile blubee's Google Play Services module from this repository. You can find more details on how to compile it here and here.&nbsp; 
Note: if you don't want to compile the module by yourself, here's the binaries files I've compiled, use it at your own risk:
Release package (Godot 2.0.2)
Debug package (Godot 2.0.2)
Release package (Godot 2.1-stable)&nbsp; 
Release package (Godot 2.1.2-stable)&nbsp; 

Step 2&nbsp;
Edit the project engine.cfg file and add the following two lines: [android]
modules="org/godotengine/godot/GodotGooglePlayServices" 
Step 3On the project export settings, edit the Custom Package and locate the GodotGooglePlayServices module file.Step 4On the same screen you'll need to select the following permissions:Access Network State
Internet

Step 5
Now you'll be able to use the module functions on your scripts. To see the full functions and callbacks available, check the README file.

Here's a sample code to show a bottom banner in test mode:
var admob = null;
var admob_banner_id = "ca-app-pub-xxxxxxxxxxxx/xxxxxxx" # your banner id here

func _ready():
 get_node("show_banner_button").connect("pressed", self, "_on_show_banner_button_pressed")
 
 if(Globals.has_singleton("bbAdmob")):
  admob = Globals.get_singleton("bbAdmob")
  #You can call admob.init_admob_test or admob.init_admob_real
  #If the third argument is true, the banner ad will be at the top of the screen
  #Function prototype init_admob_banner_test(int instance_id, string app_banner_id, boolean isTop)
  admob.init_admob_banner_test(get_instance_ID(), admob_banner_id, false)

func _on_show_banner_button_pressed():
 if admob != null:
  admob.show_banner()

You should see something like this:

And if you want to display both, banner and interstitial on the same app:
var admob = null;
var admob_banner_id = "ca-app-pub-xxxxxxxxxxxx/xxxxxxx" # your banner id here
var admob_interstitial_id = "ca-app-pub-xxxxxxxxxxxx/xxxxxxx" # your interstitial id here

func _ready():
 get_node("show_banner_button").connect("pressed", self, "_on_show_banner_button_pressed")
 get_node("show_interstitial_button").connect("pressed", self, "_on_show_interstitial_button_pressed")
 
 if(Globals.has_singleton("bbAdmob")):
  admob = Globals.get_singleton("bbAdmob")
  #You can call admob.init_admob_test or admob.init_admob_real
  #If the last argument is true, the banner ad will be at the top of the screen
  #Function prototype init_admob_banner_test(int instance_id, string app_banner_id, string app_interstitial_id, boolean isTop)
  admob.init_admob_test(get_instance_ID(), admob_banner_id, admob_interstitial_id, false)

func _on_show_banner_button_pressed():
 if admob != null:
  admob.show_banner()
  
func _on_show_interstitial_button_pressed():
 if admob != null:
  admob.show_interstitial()

This module is Android only, so you'll won't be able to run it on your computer. You'll need to export to a real device or Android emulator for that.&nbsp;&nbsp;

If you get any trouble, don't forget, logcat is your friend. Connect to your device and run via command line:
adb logcat -s godot
If you want to see the ads in action, check one of my published game.

Was this post useful for you? Feel free to buy me a beer, or just download and rate my Numbers Fusion :P

<input name="encrypted" type="hidden" value="-----BEGIN PKCS7-----MIIHNwYJKoZIhvcNAQcEoIIHKDCCByQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYCaLRzDMhywYU2r+N452GrB4IZjEtcpu2/LmPeE/sqNvDu5kRjc5B6lap5hmVFttzjJTiB+LpNIzhUSIDoRqDboXfy1vgMv0O8J/OXPgQ7FtVqzQab1opu5L3s7tZRhTsu/X3OrTjQ4wLl6JJQPaVywsbbGhZZNY5a0YX+FfuMk9TELMAkGBSsOAwIaBQAwgbQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIjNZKOWj94U+AgZAfeW30o8eoZuL8H2yr/RI+s2O07PWu3GS981tX5ofpfU/5v6c+Z43tcsfVD4E8Tjy58vKQGaO1G5Er/FD2bB8DfvNI7ooHeKUiXmQmjhA01uhtfJ38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