Android Jetpack Compose – Implement Google AdMob Banners Ads
Banner ads are rectangular images or text ads that occupy a spot within an app’s layout. If you’re new to mobile advertising, banner ads are the easiest to implement. This article shows you how to integrate banner ads from AdMob into our android application using Jetpack Compose. A sample image is given below displaying Google AdMob Banners Ads.
Step by Step Implementation
Step 1: Create a New Project in Android Studio
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. While choosing the template, select Empty Compose Activity. If you do not find this template, try upgrading the Android Studio to the latest version. We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project.
Step 2: Adding a new color in the Color.kt file
Navigate to app > java > your app’s package name > ui.theme > Color.kt file and add the code below.
Step 3: Adding dependency in build.gradle file
Navigate to app>Gradle Scripts>build.gradle file and add the below dependency to it in the dependencies section.
Sync your project after adding the dependency.
Step 4: Adding application id in AndroidManifest.xml
Navigate to app > AndroidManifest.xml file and add it before the application tag.
Step 5: Working with the MainActivity.kt file
Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.
Now run your application to see the output of it.
Please Login to comment...