How To Add Admob Ads in Android App – Admob Integration Tutorial

 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 android application. By using this method anyone can add google Admob ads on their own Android app. In our previous post, we have to make an application by using any website. 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 in the bottom of internet permission.

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

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.

compile ''

Seems like this screenshot



5. for Admob banner and Interstitial Ads: 

Finally, We need the code to run the AdMob ads on our Android app. So, Friends, we put 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 the shown in above screenshot.

                     InterstitialAd mInterstitialAd;
                    private InterstitialAd interstitial;

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 guideline.

In Conclusion:

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


Check Also

How To Make Flashlight Application in Android Studio

 Make Flashlight Application In Android : Today, Our post is How to make flashlight app ...