How To Add Admob Ads in Android App Using Android Studio

 Add Admob Ads In Android App – Admob Integration

Today, we will learn how to add AdMob ads in the android app using the android studio. So, I will discuss Admob banner & Interstitial Ads. It’s an easy method of AdMob integration in the android application. By using this method anyone can add google Admob ads on their own Android app. So, We will add Admob ads on our Android project How to Convert a Website To Android app. Therefore, we will work on this android app.

 1. ACCESS_NETWORK_STATE  in Android Manifest

First of all, we will add access_network_state permission in androidmanifest.xml. So simply open this file in the android studio and add this permission to the bottom of internet permission.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 

2.  activity_main.xml:

Now, you need to add AdMob banner ad code in activity_main.xml. Simply, place the following code at the end of the code before the</ RelativeLayout>.


Seems like the screenshot

add admob in android app

3. string.xml for AdMob ads : 

You need to add 2 string in string.xml file to place the AdMob pub ID for banner & Interstitial Ads. Therefore, add these following string in your string file. Note: you need to replace your own AdMob pub ID after the app working properly.

<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
<string name="admob_interstitial_id">ca-app-pub-3940256099942544/1033173712</string>

4. Build.gradle (module):

To run the AdMob ads we need google play services ads dependency, So please add the following dependency in the dependencies section of the build.Gradle (module) file.

implementation ''

Seems like this screenshot


5. for Admob banner and Interstitial Ads: 

Finally, We need the code to run the AdMob on our Android app. So, Friends, we put the following codes in the main

First of all, in this file, we need 4 import at the top of Therefore, add these 4 import at the top of the file.


Seems like this screenshot


Now, we will add 2 more codes below the public class MainActivity extends AppCompat which shown in the above screenshot.

 private InterstitialAd interstitial;
AdView mAdView;

In final you need to add the following code below the  setContentView(R.layout.activity_main);

 AdView mAdView = (AdView) findViewById(;
        AdRequest adRequest = new AdRequest.Builder().build();

// Prepare the Interstitial Ad
        interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID

// Prepare an Interstitial Ad Listener
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded() {
                // Call displayInterstitial() function
            public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
                if (interstitial.isLoaded()) {

Seems like this screenshot


So, friends, now you can run your app in android mobile or android emulator. I am sure you will be happy by following our guidelines. Note: Real ads code only works when u published your app on play store.

In Conclusion:

I hope you will successfully add  AdMob in your Android app by following our guidelines. If you have any problem, please share with us. We will try to reply to your comment within 2 business days.