Skip to main content

How to add banner ADs in android application on android studio ?? Step by step

Video Tutorial

First Come to that marked section



Then go to this link


Copy this code

implementation 'com.google.android.gms:play-services-ads:17.2.0' and paste it to this section

after that,go to here marked section
and check if it is in the same state. allprojects { repositories { google() jcenter() } } now come to "xml" section

write this code
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-3940256099942544/6300978111(this is your adunit id)"> </com.google.android.gms.ads.AdView>
now come to menifest section

write this extra code. <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713 (this is your app id)"/>
now come to java file
write this extra code .there will be error,red underlined some words,u will click on those word ,select that than ,from key board press "Atl+Enter" then select 'import class'
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713[this is your app id]"); mAdView = findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); now its done..!!! run it to external android device