1. Project Setup (build.gradle) 1.1 Top-level build.gradle buildscript { repositories { google() mavenCentral() } dependencies { // ... } } allprojects { repositories { google() mavenCentral() } } 1.2 App-level build.gradle dependencies { implementation 'com.google.android.gms:play-services-ads:23.0.0' // Use the latest version } After adding, sync your project with Gradle files. 2. AndroidManifest.xml Configuration Add the following inside the <application> tag: <manifest> <application> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/> <!-- Replace with your AdMob App ID --> <!-- ... other application tags --> </application> <!-- Add internet permission if not already present --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> </manifest> Note: For testing, use the sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 . Replace with your actual ID for production. 3. Initialize Mobile Ads SDK Initialize the Google Mobile Ads SDK as early as possible, ideally in your main activity's onCreate() method. import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.google.android.gms.ads.MobileAds class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) MobileAds.initialize(this) {} // The listener is optional } } 4. Banner Ads 4.1 Layout (XML) Add AdView to your XML layout (e.g., activity_main.xml ): <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Your other UI elements --> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="BANNER" <!-- Or LARGE_BANNER, FULL_BANNER, LEADERBOARD, MEDIUM_RECTANGLE, SMART_BANNER --> ads:adUnitId="ca-app-pub-3940256099942544/6300978111" > <!-- Test Ad Unit ID --> </com.google.android.gms.ads.AdView> </RelativeLayout> Note: Use the sample Ad Unit ID for testing: ca-app-pub-3940256099942544/6300978111 . Replace with your actual ID for production. 4.2 Load Ad (Kotlin) In your Activity/Fragment, load the ad: import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.AdView class MainActivity : AppCompatActivity() { private lateinit var adView: AdView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) MobileAds.initialize(this) {} adView = findViewById(R.id.adView) val adRequest = AdRequest.Builder().build() adView.loadAd(adRequest) } override fun onPause() { adView.pause() super.onPause() } override fun onResume() { super.onResume() adView.resume() } override fun onDestroy() { adView.destroy() super.onDestroy() } } 5. Interstitial Ads 5.1 Load Ad (Kotlin) import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.FullScreenContentCallback import com.google.android.gms.ads.LoadAdError import com.google.android.gms.ads.interstitial.InterstitialAd import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback class InterstitialActivity : AppCompatActivity() { private var mInterstitialAd: InterstitialAd? = null private val AD_UNIT_ID = "ca-app-pub-3940256099942544/1033173712" // Test ID override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_interstitial) MobileAds.initialize(this) {} loadInterstitialAd() findViewById<Button>(R.id.show_interstitial_button).setOnClickListener { showInterstitialAd() } } private fun loadInterstitialAd() { val adRequest = AdRequest.Builder().build() InterstitialAd.load(this, AD_UNIT_ID, adRequest, object : InterstitialAdLoadCallback() { override fun onAdFailedToLoad(adError: LoadAdError) { mInterstitialAd = null // Log or handle the error } override fun onAdLoaded(interstitialAd: InterstitialAd) { mInterstitialAd = interstitialAd mInterstitialAd?.fullScreenContentCallback = object: FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { // Called when ad is dismissed. mInterstitialAd = null // Set to null so it can be reloaded loadInterstitialAd() // Optional: reload ad instantly } override fun onAdFailedToShowFullScreenContent(adError: com.google.android.gms.ads.AdError) { // Called when ad fails to show. mInterstitialAd = null } override fun onAdShowedFullScreenContent() { // Called when ad is shown. } } } }) } private fun showInterstitialAd() { if (mInterstitialAd != null) { mInterstitialAd?.show(this) } else { // Ad not ready yet, log or show a message loadInterstitialAd() // Try loading again } } } Note: Load the interstitial ad well in advance of when you plan to show it. Use the sample Ad Unit ID for testing: ca-app-pub-3940256099942544/1033173712 . 6. Rewarded Ads 6.1 Load Ad (Kotlin) import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.LoadAdError import com.google.android.gms.ads.OnUserEarnedRewardListener import com.google.android.gms.ads.rewarded.RewardedAd import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback class RewardedActivity : AppCompatActivity() { private var rewardedAd: RewardedAd? = null private val AD_UNIT_ID = "ca-app-pub-3940256099942544/5224354917" // Test ID override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_rewarded) MobileAds.initialize(this) {} loadRewardedAd() findViewById<Button>(R.id.show_rewarded_button).setOnClickListener { showRewardedAd() } } private fun loadRewardedAd() { val adRequest = AdRequest.Builder().build() RewardedAd.load(this, AD_UNIT_ID, adRequest, object : RewardedAdLoadCallback() { override fun onAdFailedToLoad(adError: LoadAdError) { rewardedAd = null // Handle the error } override fun onAdLoaded(ad: RewardedAd) { rewardedAd = ad rewardedAd?.fullScreenContentCallback = object: FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { // Ad dismissed, can reload if needed rewardedAd = null loadRewardedAd() } override fun onAdFailedToShowFullScreenContent(adError: com.google.android.gms.ads.AdError) { // Ad failed to show rewardedAd = null } override fun onAdShowedFullScreenContent() { // Ad shown } } } }) } private fun showRewardedAd() { if (rewardedAd != null) { rewardedAd?.show(this, OnUserEarnedRewardListener { rewardItem -> // User earned reward. val rewardAmount = rewardItem.amount val rewardType = rewardItem.type // Grant reward to user here }) } else { // Ad not ready yet loadRewardedAd() } } } Note: Use the sample Ad Unit ID for testing: ca-app-pub-3940256099942544/5224354917 . 7. Testing Ads Always use test ad units during development. For real devices, you can add your device as a test device in the AdRequest.Builder() : val adRequest = AdRequest.Builder() .addTestDevice("YOUR_DEVICE_ID") // Get this from logcat when an ad loads .build() Your device ID will be printed in Logcat when an ad loads, typically with a message like: "Use new ad unit ID for this app, or test device ID: XXXXXXXXXXXXXXXX". 8. Ad Events / Callbacks Implement AdListener for Banner Ads to track lifecycle events: import com.google.android.gms.ads.AdListener import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.LoadAdError import com.google.android.gms.ads.AdView // ... inside your Activity/Fragment adView.adListener = object: AdListener() { override fun onAdLoaded() { // Code to be executed when an ad finishes loading. } override fun onAdFailedToLoad(adError: LoadAdError) { // Code to be executed when an ad request fails. } override fun onAdOpened() { // Code to be executed when an ad opens an overlay that // covers the screen. } override fun onAdClicked() { // Code to be executed when the user clicks on an ad. } override fun onAdClosed() { // Code to be executed when the user is about to return // to the app after tapping on an ad. } } Interstitial and Rewarded ads use FullScreenContentCallback for similar events.