Google AdMob is one of the most reliable and widely used mobile advertising platforms for Android app monetization. If you are developing an Android app using Kotlin, integrating banner ads is one of the simplest ways to start earning revenue.
In this article, you will learn how to integrate AdMob Banner Ads using Kotlin, using the official Google test ad unit ID. This step-by-step guide is optimized for SEO and perfect for beginners as well as experienced developers.
✅ What Is a Banner Ad in AdMob?
A banner ad is a small rectangular advertisement that occupies a part of the app screen. It refreshes automatically and displays new ads without disturbing the user experience.
Most common banner sizes:
-
320×50 (standard banner)
-
320×100 (large banner)
-
Adaptive banners (recommended)
⭐ Why Use Google Test Ad IDs?
Google strongly recommends using test ads while developing and testing your Android app.
Using real ads during development can result in:
-
Account suspension
-
Invalid traffic detection
-
Ad serving disabled
-
Policy violation warnings
Therefore, always use Google’s official test banner ID:
Test Banner Ad Unit ID
📌 Step 1: Add AdMob Dependency to build.gradle
Open app-level build.gradle and add:
Sync your project.
📌 Step 2: Add AdMob App ID in AndroidManifest.xml
Inside <application> tag, add:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
(This is Google’s official test App ID)
📌 Step 3: Add Banner View in XML Layout
Create or open your activity layout file (example: activity_main.xml) and add:
This loads the test banner ad.
📌 Step 4: Load Banner Ad in Kotlin Code
Inside your activity (example: MainActivity.kt):
⭐ Using Adaptive Banner Ads (Recommended)
Adaptive banners adjust themselves according to screen size.
Kotlin Code
No comments:
Post a Comment