How to Setup Google AdMob in Android Studio: Banner, Interstitial & Rewarded Ads

Introduction to Mobile Ad Monetization

Google AdMob is one of the world's largest mobile advertising platforms, allowing developers to monetize free Android applications with global fill rates and competitive eCPMs. However, improper integration can cause app crashes, policy violations, or ad-serving limits.

Step 1: Create Your AdMob App & Ad Units

  1. Sign in to Google AdMob.
  2. Click Apps > Add App > Android.
  3. Copy your unique AdMob App ID (format: ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX).
  4. Under Ad Units, create:
    • Adaptive Banner: For sticky placement at screen bottom.
    • Interstitial: Full-screen static/video ad shown at natural gameplay/transition pauses.
    • Rewarded Video: Opt-in rewarded ads granting in-app currency or extra lives.

Step 2: Declare AdMob App ID in AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

    <application>
        <!-- Required AdMob App ID -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-2962472897771080~1234567890"/>
    </application>
</manifest>

Step 3: Add Google Mobile Ads SDK Dependency

dependencies {
    implementation("com.google.android.gms:play-services-ads:23.3.0")
}

Step 4: Initialize the Mobile Ads SDK on App Startup

In your custom Application class or MainActivity:

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        // Initialize AdMob on a background thread
        CoroutineScope(Dispatchers.IO).launch {
            MobileAds.initialize(this@App) {}
        }
    }
}

Step 5: Loading an Interstitial Ad with Full Lifecycle Handling

class MainActivity : AppCompatActivity() {
    private var interstitialAd: InterstitialAd? = null

    private fun loadInterstitialAd() {
        val adRequest = AdRequest.Builder().build()
        InterstitialAd.load(this, "ca-app-pub-3940256099942544/1033173712", // Test Ad Unit
            adRequest, object : InterstitialAdLoadCallback() {
                override fun onAdLoaded(ad: InterstitialAd) {
                    interstitialAd = ad
                }
                override fun onAdFailedToLoad(loadAdError: LoadAdError) {
                    interstitialAd = null
                }
            })
    }

    private fun showInterstitialAd() {
        interstitialAd?.let { ad ->
            ad.fullScreenContentCallback = object : FullScreenContentCallback() {
                override fun onAdDismissedFullScreenContent() {
                    interstitialAd = null
                    loadInterstitialAd() // Preload next ad
                }
            }
            ad.show(this)
        } ?: run {
            // Ad not ready; proceed with screen transition
        }
    }
}

Always use Google Test Ad IDs during development to avoid policy strikes against your production publisher ID.

Share this Guide Help colleagues and developers learn from this article
In-Article Sponsored Content
Mohit Kumaar
AUTHOR & FOUNDER

Mohit Kumaar

Founder & CEO of JMD WORLD with 8+ Years of industrial software engineering leadership (active since 2018). Creator and manager of 500+ production Google Play applications (proprietary & client solutions) and architect of apps.jmdworld.in. Operating from Pune & Mumbai under MSME Registration: UDYAM-MH-26-1071218 and D-U-N-SĀ® 581707246.

Previous Guide

VS Code Ultimate Setup: Top 20 Extensions & Keybindings for Modern Coders

Developer Tools
Next Guide

Modern Android Architecture: Room Database vs SQLite with Kotlin Coroutines & Flow

Android Development
Recommended For You Ads by Google

Comments (0)

No comments yet. Share your thoughts below!

Leave a Comment

Share your thoughts or questions. Your email address remains private.