Interstitial Admob not working: AFMA_ReceiveMessage not defined

I have two types of ads: banner and interstitial. The first one works very well, but when I want to display an interstitial ad when I clicked the back button (but we don’t care about the button) before closing my application. But my interstitial ad is not working, and my application closes with this error in the log:

E/Ads(20984): JS: Uncaught ReferenceError: AFMA_ReceiveMessage is not defined (:1)

I do not know what this error means. I was browsing the internet and this could come from my internet connection. My wifi Or can it come from admob?

Should I try a different area with better connection?

Thanks for helping me.

+1
source share
2

InterstitialAdd:

public static void addInterstitialAd(final Activity context, final int id) {
    final InterstitialAd interstitial = new InterstitialAd(context);
    interstitial.setAdUnitId(context.getString(id));
    interstitial.loadAd(new AdRequest.Builder().build());
    interstitial.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            // Call displayInterstitial() function
            if (interstitial.isLoaded()) {
                interstitial.show();
            }
        }
    });
}

, , , :

 new Thread(new Runnable() {
        public void run() {
        final InterstitialAd interstitial = new InterstitialAd(context);
        interstitial.setAdUnitId(context.getString(id));
        interstitial.loadAd(new AdRequest.Builder().build());
        interstitial.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                // Call displayInterstitial() function
                if (interstitial.isLoaded()) {
                runOnUiThread(new Runnable() {
                public void run() {
                    interstitial.show();
                }
              });                
             }
            }
        });
     }
    }).start();

→ Admod- > admod → apclose:

@Override
    public void onBackPressed() {
        final InterstitialAd interstitial = new InterstitialAd(getApplicationContext());
        interstitial.setAdUnitId(getApplicationContext().getString(id));
        interstitial.loadAd(new AdRequest.Builder().build());
        interstitial.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                // Call displayInterstitial() function
                if (interstitial.isLoaded()) {
                    interstitial.show();
                }
            }
            @Override
            public void onAdClosed(){
                finish();
            }
            @Override
            public void onAdFailedToLoad(int errorCode){
                //you can implement continue load or finish 
            }

        });
    }
+5

, .

0

Source: https://habr.com/ru/post/1621449/


All Articles