Skip to content

Enables AdMob functionality on Godot apps that are exported to the Android platform

License

Notifications You must be signed in to change notification settings

syntaxerror247/godot-android-admob-plugin

 
 

Repository files navigation


Android Admob Plugin

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.

Prerequisites

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

Installation

There are 2 ways to install the Admob plugin into your project:

  • Through the Godot Editor's AssetLib
  • Manually by downloading archives from Github

Installing via AssetLib

Steps:

  • search for and select the Admob plugin in Godot Editor
  • click Download button
  • on the installation dialog...
    • keep Change Install Folder setting pointing to your project's root directory
    • keep Ignore asset root checkbox checked
    • click Install button
  • enable the plugin via the Plugins tab of Project->Project Settings... menu, in the Godot Editor

Installing manually

Steps:

  • download release archive from Github
  • unzip the release archive
  • copy to your Godot project's root directory
  • enable the plugin via the Plugins tab of Project->Project Settings... menu, in the Godot Editor

Usage

  • Add Admob node 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_real field of the node is set to true

Signals

  • register listeners for one or more of the following signals of the Admob node:
    • 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_refreshed(ad_id: String)
    • 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_loaded
    • consent_form_dismissed(error_data: FormError)
    • consent_form_failed_to_load(error_data: FormError)
    • consent_info_updated
    • consent_info_update_failed(error_data: FormError)

Loading and displaying ads

  • initialize the plugin
    • call the initialize() method of the Admob node
    • wait for the initialization_completed signal
  • use one or more of the following load_*() methods to load ads from the Admob node:
    • 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 Admob node 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 the Admob node with the ad_id received:
    • 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)

User Consent

  • Methods:
    • get_consent_status() - Returns a consent status value defined in ConsentInformation.gd
    • update_consent_info(params: ConsentRequestParameters) - To be called if get_consent_status() returns status UNKNOWN (0).
    • reset_consent_info() - To be used only when testing and debugging your application.
    • is_consent_form_available()
    • load_consent_form() - To be called if get_consent_status() returns status REQUIRED (2) and is_consent_form_available() returns false.
    • show_consent_form() - To be called after consent_form_loaded signal has been emitted or is_consent_form_available() returns true.

Android Export

During Android export, the plugin searches for an Admob node in the scene that is open in the Godot Editor. If not found, then the plugin searches for an Admob node in the project's main scene. Therefore;

  • Make sure that the scene that contains the Admob node is selected in the Godot Editor when building and exporting for Android, or
  • Make sure that your Godot project's main scene contains an Admob node

Troubleshooting

Missing APP ID

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.

ADB logcat

adb logcat is one of the best tools for troubleshooting unexpected behavior

  • use $> adb logcat | grep 'godot' on Linux
    • adb logcat *:W to see warnings and errors
    • adb logcat *:E to see only errors
    • adb 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




Credits

Based on Shin-NiL's Godot Admob Plugin

Developed by Cengiz

Original repository: Godot Android Admob Plugin




Tutorials

The following is a video tutorial by 16BitDev that covers the whole process of setting up Admob for your Godot app on Android.

Watch the video




All Plugins

Plugin Android iOS
Notification Scheduler https://github.com/cengiz-pz/godot-android-notification-scheduler-plugin https://github.com/cengiz-pz/godot-ios-notification-scheduler-plugin
Admob https://github.com/cengiz-pz/godot-android-admob-plugin https://github.com/cengiz-pz/godot-ios-admob-plugin
Deeplink https://github.com/cengiz-pz/godot-android-deeplink-plugin https://github.com/cengiz-pz/godot-ios-deeplink-plugin
Share https://github.com/cengiz-pz/godot-android-share-plugin https://github.com/cengiz-pz/godot-ios-share-plugin
In-App Review https://github.com/cengiz-pz/godot-android-inapp-review-plugin https://github.com/cengiz-pz/godot-ios-inapp-review-plugin

About

Enables AdMob functionality on Godot apps that are exported to the Android platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 62.2%
  • GDScript 37.8%