Enables AdMob functionality on Godot apps that are exported to the Android platform and allows displaying of Admob ads.
For iOS version, visit https://github.com/cengiz-pz/godot-ios-admob-plugin .
This branch contains the latest version of the plugin, which contains breaking changes to the plugin interface. The original version of the plugin can be found on the Release 1.0 branch.
Follow instructions on the following page to create a custom Android gradle build
Create an AdMob account at the following link:
- Google AdMob
- create an App in Admob console
- create ads for your App via the Admob console
There are 2 ways to install the Admob plugin into your project:
- Through the Godot Editor's AssetLib
- Manually by downloading archives from Github
Steps:
- search for and select the
Admobplugin in Godot Editor - click
Downloadbutton - on the installation dialog...
- keep
Change Install Foldersetting pointing to your project's root directory - keep
Ignore asset rootcheckbox checked - click
Installbutton
- keep
- enable the plugin via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor
Steps:
- download release archive from Github
- unzip the release archive
- copy to your Godot project's root directory
- enable the plugin via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor
-
Add
Admobnode to your main scene and populate the ID fields of the node- Debug IDs will only be used when your Godot app is run in debug mode
- Real IDs will only be used when the
is_realfield of the node is set totrue
-
register listeners for one or more of the following signals of the
Admobnode:initialization_completed(status_data: InitializationStatus)banner_ad_loaded(ad_id: String)banner_ad_failed_to_load(ad_id: String, error_data: LoadAdError)banner_ad_refreshed(ad_id: String)banner_ad_clicked(ad_id: String)banner_ad_impression(ad_id: String)banner_ad_opened(ad_id: String)banner_ad_closed(ad_id: String)interstitial_ad_loaded(ad_id: String)interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)interstitial_ad_impression(ad_id: String)interstitial_ad_clicked(ad_id: String)interstitial_ad_showed_full_screen_content(ad_id: String)interstitial_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)interstitial_ad_dismissed_full_screen_content(ad_id: String)rewarded_ad_loaded(ad_id: String)rewarded_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_ad_impression(ad_id: String)rewarded_ad_clicked(ad_id: String)rewarded_ad_showed_full_screen_content(ad_id: String)rewarded_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)rewarded_ad_dismissed_full_screen_content(ad_id: String)rewarded_ad_user_earned_reward(ad_id: String, reward_data: RewardItem)rewarded_interstitial_ad_loaded(ad_id: String)rewarded_interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_interstitial_ad_impression(ad_id: String)rewarded_interstitial_ad_clicked(ad_id: String)rewarded_interstitial_ad_showed_full_screen_content(ad_id: String)rewarded_interstitial_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)rewarded_interstitial_ad_dismissed_full_screen_content(ad_id: String)rewarded_interstitial_ad_user_earned_reward(ad_id: String, reward_data: RewardItem)consent_form_loadedconsent_form_dismissed(error_data: FormError)consent_form_failed_to_load(error_data: FormError)consent_info_updatedconsent_info_update_failed(error_data: FormError)
-
initialize the plugin
- call the
initialize()method of theAdmobnode - wait for the
initialization_completedsignal
- call the
-
use one or more of the following
load_*()methods to load ads from theAdmobnode:load_banner_ad(ad_request: LoadAdRequest)load_interstitia_adl(ad_request: LoadAdRequest)load_rewarded_ad(ad_request: LoadAdRequest)load_rewarded_interstitial_ad(ad_request: LoadAdRequest)
-
the
Admobnode will emit the following signals once ads have been loaded or failed to load:banner_ad_loaded(ad_id: String)banner_ad_failed_to_load(ad_id: String, error_data: LoadAdError)interstitial_ad_loaded(ad_id: String)interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_ad_loaded(ad_id: String)rewarded_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_interstitial_ad_loaded(ad_id: String)rewarded_interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)
-
once ads have been loaded, call corresponding
show_*()method from theAdmobnode with thead_idreceived:show_banner_ad(ad_id: String)show_interstitial_ad(ad_id: String)show_rewarded_ad(ad_id: String)show_rewarded_interstitial_ad(ad_id: String)
- Make sure that the scene that contains the Admob node is selected in the Godot Editor when building and exporting for Android
- Close other scenes to make sure
- Admob node will be searched in the scene that is currently open in the Godot Editor
If your game crashes due to missing APP ID, then make sure that you enter your Admob APP ID in the Admob node and pay attention to the Android Export section.
If you're getting the following error or any error related to the plugin's icon.png file:
Godot Engine v4.?.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started ---
--- GDScript language server started on port ? ---
res://addons/[?]Plugin/[?]ExportPlugin.gd:21 - Parse Error: Preload file "res://addons/[?]Plugin/icon.png" has no resource loaders (unrecognized file extension).
res://addons/[?]Plugin/[?]ExportPlugin.gd:70 - Parse Error: Could not find type "[?]" in the current scope.
...
then reimport the res://addons/[?]Plugin/icon.png file from Godot Editor's context menu.
adb logcat is one of the best tools for troubleshooting unexpected behavior
- use
$> adb logcat | grep 'godot'on Linuxadb logcat *:Wto see warnings and errorsadb logcat *:Eto see only errorsadb logcat | grep 'godot|somethingElse'to filter using more than one string at the same time
- use
#> adb.exe logcat | select-string "godot"on powershell (Windows)
Also check out: https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html#troubleshooting
Based on Shin-NiL's Godot Admob Plugin
Developed by Cengiz
Original repository: Godot Android Admob Plugin