Get Started
Integrating the AdMob plugin into your Godot project, specifically for Godot v4.1+, is the initial and crucial step in enabling ad displays and revenue generation. After successfully incorporating this plugin, you'll have the flexibility to select from various ad formats, like Banner or Interstitial, and proceed with the necessary implementation steps.
This document is based on:
Prerequisites
- Use Godot v4.1 or higher
- Deploy Android:
minSdkVersion
of 19 or highercompileSdkVersion
of 28 or higher
- Deploy iOS:
- Use Xcode 14.1 or higher
- Target iOS 11.0 or higher
- CocoaPods
- Recommended: Create an AdMob account and register an app.
Download the Godot AdMob Plugin from Poing Studios
The Godot AdMob Plugin from Poing Studios simplifies the process for Godot developers to incorporate Google Mobile Ads into their Android and iOS apps, eliminating the need to write Java/Kotlin or Objective-C++ code. Instead, this plugin offers a GDScript-based interface for ad requests, which can be seamlessly integrated into your Godot project.
To access the plugin, you can either download the Godot package provided or explore its source code on GitHub through the links below.
Download from GitHub Download from AssetLibrary Source Code
Importing the Godot AdMob Plugin on Project
The AdMob plugin for Godot is conveniently available via AssetLib. To import this plugin into your Godot project, follow these steps:
- Open your Godot project.
- Navigate to AssetLib within the Godot editor.
- In the search bar, enter
AdMob
and ensure that the publisher is set topoing.studios
. - Locate the AdMob plugin and click the
Download
button. - Once the download is complete, go to
Project > Project Settings
within the Godot editor. - In the
Plugins
section, find theAdMob
plugin and activate it. - With these steps, you'll have successfully integrated the AdMob plugin into your Godot project without the need for additional manual file imports.
Obtaining external libraries
To integrate the required Android library for AdMob in Godot, follow these steps:
- In Godot, navigate to
Project > Tools > AdMob Download Manager > Android > LatestVersion
. - This action will download the appropriate Android library into your project, which is located at
res://addons/admob/downloads/android/
.
If you encounter any issues with the download, you can try downloading the library manually by clicking here.
To integrate the required iOS library for AdMob in Godot, follow these steps:
- In Godot, navigate to
Project > Tools > AdMob Download Manager > iOS > LatestVersion
. - This action will download the appropriate iOS library into your project, which is located at
res://addons/admob/downloads/ios/
.
If you encounter any issues with the download, you can try downloading the library manually by clicking here.
Installing
- Install the Android Build Template by navigating to
Project > Install Android Build Template
. - Go to the directory
res://android/plugins/
and extract the contents of theads
folder from the downloaded.zip
located atres://addons/admob/downloads/android/
. If you have Mediation, do the same formeta
,adcolony
etc.... - Add your AdMob App ID to your app's
res://android/build/AndroidManifest.xml
file by adding a<meta-data>
tag with namecom.google.android.gms.ads.APPLICATION_ID
, as shown below. If you don't do this then you App will crash on start-up. - When exporting your project, select
Use Custom Build
and ensure thatAd Mob
is enabled, If you have Mediation, also markAd Mob Meta
,Ad Mob AdColony
etc...
- Create the iOS Plugin folder if doesn't exists on
res://ios/plugins/
. - Go to the directory
res://ios/plugins/
and extract the contents of theads
folder from the downloaded.zip
located atres://addons/admob/downloads/ios/
. If you have Mediation, do the same formeta
,adcolony
etc.... - Within
res://ios/plugins/poing-godot-admob-ads.gdip
, if you are using Mediation, locate theSKAdNetworkItems
section. Here, you can remove the comments associated with the Mediation Networks that you are using. - When exporting your project, update the
GADApplicationIdentifier
with your AdMob App ID and and ensure thatAd Mob
is enabled, If you have Mediation, also markAd Mob Meta
,Ad Mob AdColony
etc... - Once exported, go to
{{ ios_xcode_export_folder }}/{{your_project_name}}/ios/plugins/poing-godot-admob/scripts/
folder and open the terminal (must be inside this folder) and run these commands: - This will create for your a
{{ your_project_name }}.xcworkspace
(e.g.:AdMobAddon.xcworkspace
) file on your{{ ios_xcode_export_folder }}
, open this file. - Go to the Target of your Application and them
General -> Frameworks, Libraries, and Embedded Content
and add allPods
in section. - Select all Frameworks (⌘ + A) and put as
Do Not Embed
- Run the Game.
- If you are trying to run on Simulator and is not working read this.
Initialize the Google Mobile Ads SDK
Prior to loading ads, ensure that your application initializes the Google Mobile Ads SDK. You can accomplish this by calling MobileAds.initialize(). This function initializes the SDK and triggers a completion listener once the initialization process is finished, or if it exceeds a 30-second timeout. It's important to note that this initialization should occur only once, ideally during the app's launch phase.
If you are utilizing mediation, it's essential to wait for the completion handler to be called before proceeding with ad loading. This step ensures that all mediation adapters are properly initialized before ad requests are made.
Select an ad format
The Google Mobile Ads SDK is now successfully imported, and you are prepared to integrate an ad into your app. AdMob provides a variety of ad formats, allowing you to select the one that aligns best with your app's user experience.
Banner
Banner ads are rectangular advertisements, consisting of either images or text, that are integrated into an app's layout. These ads remain on the screen while users engage with the app and can automatically refresh after a designated time interval. If you're new to mobile advertising, banner ads provide an excellent starting point for your ad implementation journey.
Interstitial
Interstitial ads are expansive, full-screen advertisements that overlay an app's interface and persist until they are closed by the user. They are most effective when strategically placed during natural pauses in the app's execution, such as between levels of a game or immediately after the completion of a task.
Rewarded
Rewarded video ads are immersive, full-screen video advertisements that provide users with the choice to watch them entirely. In return for their time and attention, users receive in-app rewards or benefits.
Rewarded Interstitial
A Rewarded Interstitial is a specific form of incentivized ad format that allows you to provide rewards in exchange for ads that appear automatically during natural app transitions. Unlike regular rewarded ads, users are not obligated to actively opt in to view a Rewarded Interstitial; they are seamlessly integrated into the app experience.