In this article I will be giving you steps to integrate Google Ads (Admob) using the new Android Plugin System, which was introduced with Godot 3.2. This new system makes it possible to integrate Google Ads without having to create new templates. But instead it makes it possible to automatically include plugins when you build the game for Android. Meaning we don’t have to rebuild any templates on a Godot version change. This also streamlines the process for integrating Admob into the game.

Before you continue, make sure you have done all the steps to make it possible to Export to Android. There is a tutorial available on this here that walks you through the process. Once you have done those steps you can come back to this tutorial.

Godot 3.2 was not fully released yet during the creation of this tutorial. Instead I have used Godot 3.2 RC2. Which you can find the download links for here. (Edit: updated link to latest version)

Install Android Build Template

Navigate to Project and select “Install Android Build Template” to install the Android Build Templates, which make it possible to load Android plugins.

Example of the “Install Android Build Template” button.

Select install. A template gets installed to “res://android/build” this makes it possible to configure or customize the build by changing the contents in that path.

Select install with the confirm.

Set Custom Build SDK Path

When you are on Godot 3.2 you can select a path for the Custom Build Sdk Path. On my device it is the following:

C:\Users\UserName\AppData\Local\Android\Sdk

If you are unsure of your current path, you can go to Android Studio, select Configure, SDK Manager.

And you will be able to see your Android SDK Location.

Example of how to find the SDK path

Accepting the Android SDK licence

Open the Custom SDK path. And navigate to “tools\bin“

C:\Users\UserName\AppData\Local\Android\Sdk\tools\bin

Example of the bin path

Select File, go to Open Windows PowerShell and select Open Windows Powershell as administator

How to navigate to Open Windows Powershell as administrator

Once you have powershell open, you run this command. Afterwards, read and decide on your own to accept the licences by pressing Y. You will have to accept multiple licences.

.\sdkmanager --licenses

Toggle the “Use Custom Build” option

To get started we have to toggle the Use Custom Build option in the Export menu. In order to get there, you have to go to go to the export options.

Navigate to Export Menu

After you open the export menu, make sure “Runnable” is set on the current preset. This is now required if you want to do a quick run from the main screen. Afterwards, toggle the ““Use Custom Build”” toggle box.

Toggle Runnable and Use Custom Build

Do a test build

Before continuing, we test if a custom build is possible. In order to quickly do this, you can use the button on the top right corner. After running you will see a console window that may install multiple packages.

Run on device

Installing the Admob plugin from Shin-NiL

To obtain the plugin can navigate here. The plugin currently supports banners, interstitial ads and rewarded videos. If you love what this developer is doing, make sure to give him a donation. You can find a Paypal link on the Github page.

Download the plugin

When you have navigated to the Github page, press “Clone or download” and “Download ZIP”. Once you have downloaded the file. Unpack it somewhere on your computer.

Place the admob-plugin folder in the Android folder of your project.

The quickest way of getting to the Android folder is by right clicking res:// and opening the folder named Android in your file explorer.

Example of how to navigate to the android folder

Add permissions in export options

Navigate to “Project” and select “Export”

On the right side, you will have to scroll down and find the “Access Network State” toggle box. And toggle it. Since Admob requires a internet connection.

Now you have to scroll down quite a bit more and toggle the “Internet” toggle box.

Set modules in project settings

In order for the Admob module to load we have to navigate to the Project Settings, go to the Android Tab. And set the module text to the following:

org/godotengine/godot/GodotAdMob

Testing if the module loads properly

Navigate to the zip folder that came from the Github website. And go to the demo folder.

Place the main.gd and main.tscn in the root of your project. Then you can set the main.tscn scene as the main scene to load upon startup. In case you have a pixel art project, the elements in the scene will be too big, so you will have to rescale the buttons and text to test it properly!

In order to do this you have to go to the project settings. By pressing on the “Project” button and then navigating to “Project Settings…”

And then you can set the Main Scene by going to “Run” in under the tab called “Application”

Afterwards, try to build and test the project on your mobile phone.

Global advertisement loader script

I’ve chosen to create a custom script that is based on the demo script from Shin-NiL. Reason for this is because I felt the script provided missed some features that are mandatory if you want to launch a game. Such as automatic connection retrying and settings for child directed ads. Even with these additions, chances are you may want to modify it more to your liking. You can find all the methods you can call on the admob object in the GitHub repository.

You can copy the code below and paste it into a script. I’ve called it admanager.gd but you can name it what you like. In order to make the script global, go to Project Settings>Auto Load>Browse for path>Set a name (I use admanager). This way you can call admanager.showInterstitial() ,admanager.showBanner() and admanager.showRewarded() from anywhere in your project. It will return true or false if it was able to show them. This script is just a starting point for you to expand upon.