3

I´ve displayed Facebook ads before but today the Interstitial ads stopped working, we I try the debug mode I get an error with code -1 and name Unknown error.

I'm using the following code:

fbInterstitialAd =new com.facebook.ads.InterstitialAd(mContext,id_facebook);
    fbInterstitialAd.setAdListener(new InterstitialAdListener() {
        @Override
        public void onInterstitialDisplayed(Ad ad) {

        }

        @Override
        public void onInterstitialDismissed(Ad ad) {
            adDismissed.run();
        }

        @Override
        public void onError(Ad ad, AdError adError) {
            Log.d("FBads",adError.getErrorMessage());
        }

        @Override
        public void onAdLoaded(Ad ad) {
            adLoaded.run();
        }

        @Override
        public void onAdClicked(Ad ad) {
            adClickedCallback.run();
        }
    });
    fbInterstitialAd.loadAd();
David
  • 75
  • 1
  • 9

2 Answers2

1

Had same issue. I suggest you to download Facebook latest version library and re-import it. Hope it will solve it

parik dhakan
  • 787
  • 4
  • 19
1

New Facebook SDK Code: Try this Once

// Declare the InterstitialActivity in AndroidManifest.xml:
//  <activity android:name="com.facebook.ads.InterstitialAdActivity"
//            android:configChanges="keyboardHidden|orientation" />
// In the Activity that will launch the interstitial,
// implement the AdListener interface and add the following:

import com.facebook.ads.*;

private InterstitialAd interstitialAd;

private void loadInterstitialAd() {
    interstitialAd = new InterstitialAd(this, "id_facebook");
    interstitialAd.setAdListener(this);
    interstitialAd.loadAd();
}

@Override
public void onError(Ad ad, AdError error) {
    // Ad failed to load
}

@Override
public void onAdLoaded(Ad ad) {
    // Ad is loaded and ready to be displayed
    // You can now display the full screen add using this code:
    interstitialAd.show();
}
Ramesh R
  • 7,009
  • 4
  • 25
  • 38