Add AdMob Ad banner: using Android Compose
2 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:
- Register to get an AdMob account.
- Using the latest stable Android Studio, create new Android Compose project. Open Android Studio -> new -> compose -> name project -> ok
- Now you have an Android compose Hello world project. Build and run.
- Next let’s add the AdMob SDK Android integration.
- 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)…