Banner And Interstitial ADS Add in app 

Aslam o Alikum friends. Today we can discuss about Admob ads. A lots of people have same question that is “Why my ads are not showing in app “. There are several reason but main reason is not choosing right dependency so kindly read my article carefully if you miss any step ads will not shown.


There are several steps and all steps are very important so kindly don’t miss any step other wise ads will not show on your app.

  1. First step is to add dependency to your android project location is Build.Gradule.
  2. For banner we can use xml code with ID and that id we can access in Java class.
  3. For interstitial Ads we cannot need xml code.


Dependency Buidl.gradule

Important Note!! If you are using firebase dependency  v17.0 then admob v12.0 dependency cannot work so if you use firebase with admob then you can add admob v15.0 dependency.

implementation ''


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

Java Activity Imports for banner ads


XML Code For Banner Ads


Banner Ads for java code

 AdView mAdView;
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdView = findViewById(;
AdRequest adRequest = new AdRequest.Builder().build();

Java Activity Import for interstitial ads



Banner Ads for java code

 private InterstitialAd mInterstitialAd;
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override public void onAdClosed()
{ mInterstitialAd.loadAd(new AdRequest.Builder().build()); } });

Function code

 public void Intertialshow()
{ if (mInterstitialAd.isLoaded()) {; }
{ finish(); } }

On Back Pressed Button Code

 public void onBackPressed() { Intertialshow(); }

So friends this is the code of banner ads  and interstitial ads. In next articles we well discuss the reward video ads and native ads. Banner ads cpc is less then interstitial ads so use interstitial ads. Video reward ads cpc is greater than interstitial ads. So next article we will discuss reward and native ads.

If you have any problem about admob ads kindly mention in comment section.

One thought on “Banner And Interstitial ADS Add in app Android Studio”

  1. bro thank you so much but how to add timer for this
    i have app contain 20 button, everytime you click button show ad, for that this violate admob policies
    so how to add timer , and is that code work for buttons ?

Leave a Reply

Your email address will not be published. Required fields are marked *