0

The interstitial ad is not being shown...

I have the play_services_lib included in the project and there are no errors.

The following code is in my Activity:

import com.google.android.gms.ads.*;
import com.google.android.gms.ads.AdRequest;

            onCreate(){
            // Create the interstitial.
            interstitial = new InterstitialAd(this);
            interstitial.setAdUnitId("ca-app-pub-...");

            // Create ad request.
            AdRequest adRequest = new AdRequest.Builder().build();

            // Begin loading your interstitial.
            interstitial.loadAd(adRequest);
            interstitial.setAdListener(new AdListener(){
                  public void onAdLoaded(){
                       displayInterstitial();
                  }
        });
}

// Invoke displayInterstitial() when you are ready to display an interstitial.
  public void displayInterstitial() {
    if (interstitial.isLoaded()) {
      interstitial.show();
    }
  }

Manifest.xml

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    <meta-data android:name="com.google.android.gms.version"
       android:value="@integer/google_play_services_version" />

Do I still need the following(It is from where I used the old admob sdk)

<activity
        android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

    <meta-data
        android:name="ADMOB_PUBLISHER_ID"
        android:value="pub-..." />
remudada
  • 3,751
  • 2
  • 33
  • 60

3 Answers3

2

The problem was the following: I still used the old import in manifest file:

<activity   android:name="com.google.ads.AdActivity"

instead of

<activity   android:name="com.google.android.gms.ads.AdActivity"
2

Are you using the same ca-app-pub-#### for your banners and interstitials? If so, you shouldn't. Save yourself a few hours of debugging :)

Bruno Carrier
  • 530
  • 5
  • 8
1

There is a real possibility that there is no inventory. This happens to us rather frequently. See the logs and check if the ad is indeed loaded successfully.

Also , remember that interstitials take a bit of time to load. It's not uncommon to get an ad unit after 80-90 seconds. Make sure you wait sufficiently.

Looking closely at your code, this is slightly different from the official guide!

Try following that exactly https://developers.google.com/mobile-ads-sdk/docs/admob/advanced

remudada
  • 3,751
  • 2
  • 33
  • 60
  • The log says that the ad is not loaded at all (The listener is not invoked). Yeah I already waited 2 minutes. –  Jul 11 '14 at 09:10
  • Added more info to the answer, looks like you are not following the guide exactly – remudada Jul 11 '14 at 09:16
  • Does not work. In their sample project they also use the adListener –  Jul 11 '14 at 10:17