Skip to main content
Version: v2.0

Get Started

App prerequisites

  1. Use Android Studio 3.2 or higher
  2. Make sure that your app's build file uses the following values:
  • A minSdkVersion of 23 or higher
  • A compileSdkVersion of 35 or higher

Configure your app

  1. In your project-level build.gradle file, include Google's Maven repository and Maven central repository in both your buildscript and allprojects sections:
buildscript {
repositories {
google()
mavenCentral()
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}
  1. Add the dependencies for the Mobile Ads SDK to your module's app-level Gradle file, normally app/build.gradle:
dependencies {
implementation 'com.google.android.gms:play-services-ads:25.2.0'
}
  1. Add your app ID (identified in the PremiumAds Publishers Dashboard) to your app's AndroidManifest.xml file.
<manifest>
<application>
<!-- Sample app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
In a real app, please use your actual App ID, not the one listed above.

Initialize the Mobile Ads SDK

Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() which initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally at app launch.

Important: Call MobileAds.initialize() on a background thread. The call performs I/O and can block the main thread, which may degrade your app's startup performance.

Here's an example of how to call the initialize() method in an Activity:

import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize the Mobile Ads SDK on a background thread.
new Thread(
() -> {
MobileAds.initialize(this, initializationStatus -> {});
})
.start();
}
}