This guide is intended for publishers integrating an early access build of the Google Mobile Ads Android SDK into their Android app. Early access builds provide the opportunity to take advantage of new Google Mobile Ads SDK features without waiting for the next release of Google Play services, and offer the following benefits:
They automatically start using the newer Google Mobile Ads SDK implementation from the Google Play services APK once the early access feature launches in the APK.
They're fully tested and meet the same criteria for release as public builds available in Google's Maven repository or the SDK Manager.
They're full versions of the Google Mobile Ads SDK, which are larger than the Lite SDK, but are not subject to the limitations of the Lite SDK.
They can be used globally and not only in apps distributed through Google Play.
Follow the steps on this page to set up a local Maven repository with the early access Google Mobile Ads SDK and reference it as a dependency in your Android app.
Prerequisites
- Use Android Studio 3.0 or higher
- Target Android API level 16 or higher
- Early access Google Mobile Ads SDK zip file provided by Account Manager
Configure custom Maven repository
Download the early access Google Mobile Ads SDK zip file. Create a
gma_sdk_repo
folder in your project's top-level directory, and place the
entire contents of the zip in that folder. Your directory structure should look
like <project_root_dir>/gma_sdk_repo/com/google/...
.
Open your app's project level build.gradle
file.
allprojects {
repositories {
maven {
url "${project.rootDir}/gma_sdk_repo"
}
google()
jcenter()
}
}
Add the line in bold to the allprojects/repositories
section. This instructs
Gradle to look for a Maven repository in the gma_sdk_repo
folder you just
created when resolving dependencies.
Add build dependency
To use the early access build of the Google Mobile Ads SDK in your project, you
also need to reference it as a dependency in your app-level build.gradle
file:
Open the app-level build.gradle
file and add the bolded line in the snippet to
the dependencies
section.
dependencies {
implementation 'com.google.android.gms:play-services-ads:<span class="notranslate">16.7.1</span>'
}
...
Resolve Firebase conflicts
If you're using a Firebase library along with the Mobile Ads SDK, you could have
both the com.google.android.gms:play-services-measurement-api
and
com.google.android.gms:play-services-measurement-sdk-api
dependencies included
in your project. The versions of these two dependencies must match, but you
might find that your Mobile Ads SDK early access build and your current version
of Firebase pulled in different versions for these two dependencies.
As a workaround, you can force resolve the dependency to a specific version
of the play-services-measurement-sdk-api
library in your app's build.gradle
file as follows:
android {
...
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-measurement-sdk-api:x.y.z'
}
}
}
...
The version x.y.z
depends on your version of Firebase. Here are the correct
versions for recent Firebase releases:
firebase-core version
|
play-services-measurement-sdk-api version
|
---|---|
16.0.7
|
16.3.0
|
16.0.6
|
16.0.4
|
16.0.5
|
16.0.3
|
16.0.4
|
16.0.2
|
To look up the correct version for other Firebase versions, run
gradle androidDependencies
for your app and use the version printed for
the com.google.android.gms:play-services-measurement-api
dependency.
Your Android app is now ready to use with an early access build of the Google Mobile Ads Android SDK.