Admob banner ad integration in Andriod Studio

Admob integration becomes very easy with the Android Studio. No need to include .jar file or google play service lib like in Eclipse. Follow the steps to include admob banner to your app.


  1. Make sure you’ve updated the “Extra” part of your android sdk. Because we need here Google Repository. Now add the following line to dependencies area of your app’s gradle file.
    compile ''

    After pasting this line, check the bottom part of the android studio where it will suggest you to change the version of google play service ads. Because it might be possible that there will be new version of google play service ads. Now click on “sync now” at the top of android studio and you are ready to go.

  2. Now open the AndroidManifest.xml file and include following in different part of the file. First add two permission in the <manifest> tag and out side of <application> tag.
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    Now add meta data in your <application> tag.

    android:value="@integer/google_play_services_version" />

    Now add admob activity in application tag same as meta data.

    android:theme="@android:style/Theme.Translucent" />
  3. Then add the below xml code in your xml layout file where you want to display ad. It’s a good practice to surround your ad with relative layout. So that you can easily hide the ad until it’s load without affecting the rest of your layout.

    Make sure that you set the visibility of the ad to “gone” in xml file. Because we will hide the ad until it loads completely or there will be blank white space until the ad loads from server and it looks bad. Do not forget to replace YOUR_AD_UNIT_ID with your actual Ad unit id created from admob dashboard.

  4. And finally add the following code in your respective Activity file and that’s it! The ad should be loaded.
    final AdView mAdView = (AdView) findViewById(;
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.setAdListener(new AdListener() {
      public void onAdLoaded() {

    It will display the ad once it loaded completely.

You can check the detailed explanation of everything in this tutorial as well as other information about integration here on Google Developers site and download sample app from there.

If you have any issues in the above code, please write them below in comment section. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s