Member-only story

Android Compose: Add AdMob Ad banner

Andres Sandoval
3 min readNov 29, 2021

--

Tutorial shows how to display Google AdMob banner ads using Android Compose. Follow the below steps to load an Android test bottom ad banner using Google’s AdMob SDK.

Steps:

  1. Register to get an AdMob account.
  2. Using the latest stable Android Studio, create new Android Compose project. Open Android Studio -> new -> compose -> name project -> ok
  3. Now you have an Android compose Hello world project. Build and run.
  4. Next let’s add the AdMob SDK Android integration.
  5. Add the Gradle AdMob dependency -> build.gradle -> add below and sync project:
implementation 'com.google.android.gms:play-services-ads:20.5.0'

6. Add the APPLICATION_ID inside the file AndroidManifest.xml <application> — for testing use test key

<application...
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
</application>

8. Add Composable banner in your compose MainActivity — for testing use test key. Add the function AdvertView().

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)…

--

--

Andres Sandoval
Andres Sandoval

Written by Andres Sandoval

I'm a passionate Android Software Engineer with over 11 years of experience. andresand.github.io/andres-about-me/ buymeacoffee.com/andresand

Responses (2)