Get Started Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Google Mobile Ads C++ SDK is deprecated as of June 17, 2024, with End-of-Maintenance on June 17, 2025, and new projects should use the native iOS and Android AdMob SDKs instead.
This guide is for integrating the deprecated Google Mobile Ads C++ SDK into a C++ app for monetization with AdMob, specifically without using Firebase.
To integrate the SDK, you need to meet platform-specific prerequisites for Android and iOS, and set up your app in your AdMob account to get an AdMob app ID.
The Google Mobile Ads C++ SDK is installed by downloading the Firebase C++ SDK, as the GMA C++ SDK resides within the
firebase::gmanamespace, and platform-specific configurations are required.Before loading ads, the Google Mobile Ads C++ SDK must be initialized by calling
firebase::gma::Initialize(), ideally at app launch, and its completion can be monitored using afirebase::Future.After initializing the SDK, you can select an ad format such as Banner, Interstitial, or Rewarded to implement ads in your app.
Instead of the Google Mobile Ads C++ SDK, consider using theiOS andAndroid SDKs from AdMob. For support, reach out to thecontact us form.
This guide is for publishers who want to monetize a C++ app with AdMob, withoutusing Firebase. If you plan to include Firebase in your app—or if you'reconsidering it—see theAdMob withFirebase version of thisguide instead.
Integrating the Google Mobile Ads C++ SDK into an app is the first step towarddisplaying ads and earning revenue. Once you've integrated the SDK, you canchoose an ad format, such as interstitial or rewarded, and follow the steps toimplement it.
The Google Mobile Ads C++ SDK wraps the Google Mobile Ads iOS and Android SDKs,and is only available on those platforms. The Google Mobile Ads C++ SDK makesuse of Firebase C++ constructs to support asynchronous operations, so it residesin thefirebase::gma namespace.
If this is your first time going through this guide, we recommend that youdownload and follow along using theGoogle Mobile Ads C++ testapp.
Prerequisites
Android
- Use Android Studio 3.2 or higher
- Make sure that your app's build file uses the following values:
- A
minSdkVersionof 16 or higher - A
compileSdkVersionof 28 or higher
- A
iOS
- Use Xcode 13 or higher
- Target iOS 10.0 or higher
Set up your app in your AdMob account
Register your app as an AdMob app by completing the following steps:
Sign in to orsign upfor an AdMob account.
Register your app withAdMob. This step creates an AdMobapp with a uniqueAdMob app IDthat is needed later in this guide.
Install the Google Mobile Ads C++ SDK
Since the Google Mobile Ads C++ SDK resides in thefirebase::gma namespace,download theFirebase C++ SDK,and then unzip it to a directory of your choice.
The Firebase C++ SDK is not platform-specific, but it does requireplatform-specific library configurations.
Android
We recommend using CMake, but you can find instructions for ndk-build in ourgeneralFirebase C++ SDK Get StartedGuide tolinklibfirebase_app.a andlibfirebase_gma.a to your app.
In your project's
gradle.propertiesfile, specify the location of theunzipped SDK:systemProp.firebase_cpp_sdk.dir=FULL_PATH_TO_SDKTo your project's
settings.gradlefile, add the following content:def firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')gradle.ext.firebase_cpp_sdk_dir = "$firebase_cpp_sdk_dir"includeBuild "$firebase_cpp_sdk_dir"To your module (app-level) Gradle file—usually
app/build.gradle— add the following content, which includes thelibrary dependency for the Google Mobile Ads C++ SDK.android.defaultConfig.externalNativeBuild.cmake { arguments "-DFIREBASE_CPP_SDK_DIR=$gradle.firebase_cpp_sdk_dir"}# Add the dependency for the Google Mobile Ads C++ SDKapply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"firebaseCpp.dependencies { gma}To your project's
CMakeLists.txtfile, add the following content.# Add Firebase libraries to the target using the function from the SDK.add_subdirectory(${FIREBASE_CPP_SDK_DIR}bin/EXCLUDE_FROM_ALL)# Add the Google Mobile Ads C++ SDK.# The Firebase C++ library `firebase_app` is required,# and it must always be listed last.set(firebase_libsfirebase_gmafirebase_app)target_link_libraries(${target_name}"${firebase_libs}")Sync your app to ensure that all dependencies have the necessary versions.
iOS
The steps in this section are an example of how to add the Google Mobile AdsC++ SDK to your iOS project.
Get CocoaPods version 1 or later by running:
sudogeminstallcocoapods--preAdd the Google Mobile Ads pod from the unzipped SDK.
Create a Podfile if you don't already have one:
cdAPP_DIRECTORYpodinitTo your Podfile, add the pods for the Google Mobile Ads C++ SDK, theGoogle User Messaging Platform SDK, and the minimal Firebase core SDK(required by the GMA C++ SDK):
pod 'Firebase/CoreOnly'pod 'Google-Mobile-Ads-SDK'pod 'GoogleUserMessagingPlatform'Install the pods, then open the
.xcworkspacefile in Xcode.podinstallopenAPP.xcworkspaceAdd the following frameworks from the Firebase C++ SDK to the project:
xcframeworks/firebase.xcframeworkxcframeworks/firebase_gma.xcframework
You're all set! Your C++ app is configured to use the Google Mobile Ads C++ SDKwithout any other Firebase services.
Configure your app's AdMob app ID
Android
Follow step 3 ofConfigure your app as described by theMobile Ads SDKAndroid guideand then come back to this page.
Note: Make the changes to theAndroidManifest.xml file only—ignoresteps 1 and 2 in that guide.iOS
Follow theUpdate your Info.plist step as described by theMobile Ads SDKiOS guide and then come backto this page.
Initialize the Google Mobile Ads SDK
Before loading ads, have your app initialize the Google Mobile Ads C++ SDK bycallingfirebase::gma::Initialize() which initializes the SDK and completes afirebase::Future once initialization is complete (or after a 30-secondtimeout). This needs to be done only once, ideally at app launch.
Ads may be preloaded by the Google Mobile Ads C++ SDK or mediation partner SDKsupon callingInitialize(). If you need to obtain consent from users in theEuropean Economic Area (EEA), set any request-specific flags (such astag_for_child_directed_treatment ortag_for_under_age_of_consent), orotherwise take action before loading ads, ensure you do so by invokingfirebase::gma::SetRequestConfiguration() before initializing the Google MobileAds C++ SDK. For more information see ourTargeting guide.
Here's an example of how to callInitialize():
Android
// Initialize the Google Mobile Ads libraryfirebase::InitResultresult;Future<AdapterInitializationStatus>future=firebase::gma::Initialize(jni_env,j_activity,&result);if(result!=kInitResultSuccess){// Initialization immediately failed, most likely due to a missing// dependency. Check the device logs for more information.return;}// Monitor the status of the future.// See "Use a Future to monitor the completion status of a method call" below.if(future.status()==firebase::kFutureStatusComplete&&future.error()==firebase::gma::kAdErrorCodeNone){// Initialization completed.}else{// Initialization on-going, or an error has occurred.}iOS
// Initialize the Google Mobile Ads library.firebase::InitResultresult;Future<AdapterInitializationStatus>future=firebase::gma::Initialize(&result);if(result!=kInitResultSuccess){// Initialization immediately failed, most likely due to a missing// dependency. Check the device logs for more information.return;}// Monitor the status of the future.// See "Use a Future to monitor the completion status of a method call" below.if(future.status()==firebase::kFutureStatusComplete&&future.error()==firebase::gma::kAdErrorCodeNone){// Initialization completed.}else{// Initialization on-going, or an error has occurred.}Use aFuture to monitor the completion status of a method call
AFuture provides you a way to determine the completion status of yourasynchronous method calls.
For example, when your app callsfirebase::gma::Initialize(), a newfirebase::Future is created and returned. Your app can then poll thestatus() of theFuture to determine when the initialization has completed.Once complete, your app can invokeresult() to obtain the resultingAdapterInitializationStatus.
Methods that return aFuture have a corresponding "last result" method thatapps can use to retrieve the most recentFuture for a given action. Forexample,firebase::gma::Initialize() has a corresponding method calledfirebase::gma::InitializeLastResult(), which returns aFuture that your appcan use to check the status of the last call tofirebase::gma::Initialize().
If the status of theFuture is complete and its error code isfirebase::gma::kAdErrorCodeNone, then the operation has completedsuccessfully.
You can also register callbacks to be invoked when aFuture is completed. Insome cases, the callback will be running in a different thread, so make sureyour code is thread-safe. This code snippet uses a function pointer for thecallback:
// Registers the OnCompletion callback. user_data is a pointer that is passed verbatim// to the callback as a void*. This allows you to pass any custom data to the callback// handler. In this case, the app has no data, so you must pass nullptr.firebase::gma::InitializeLastResult().OnCompletion(OnCompletionCallback,/*user_data=*/nullptr);// The OnCompletion callback function.staticvoidOnCompletionCallback(constfirebase::Future<AdapterInitializationStatus>&future,void*user_data){// Called when the Future is completed for the last call to firebase::gma::Initialize().// If the error code is firebase::gma::kAdErrorCodeNone,// then the SDK has been successfully initialized.if(future.error()==firebase::gma::kAdErrorCodeNone){// success!}else{// failure.}}Select an ad format
The Google Mobile Ads C++ SDK is now imported and you're ready to implement anad. AdMob offers a number of different ad formats, so you can choose the onethat best fits your app's user experience.
Banner
Rectangular ads that appear at the top or bottom of the device screen.Banner ads stay on screen while users are interacting with the app, and canrefresh automatically after a certain period of time. If you're new to mobileadvertising, they're a great place to start.
Interstitial
Full-screen ads that cover the interface of an app until closed by the user.They're best used at natural pauses in the flow of an app's execution, such asbetween levels of a game or just after a task is completed.
Rewarded
Ads that reward users for watching short videos and interacting with playableads and surveys. Used for monetizing free-to-play apps.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.