react-native-admob icon indicating copy to clipboard operation
react-native-admob copied to clipboard

Error: Ad is already loaded. (Warning)

Open bvv218 opened this issue 7 years ago • 13 comments

I am trying to implement Admob Rewarded, and I have code similar to the one from Example folder. Everything works great but I receive warning in console that says Error: Ad is already loaded. and another warning on the phone {"framesToTop":1",code":"E_AD_ALREADY_LOADED"}. I receive it right after the page loads (before even clicking a button with an ad). Am I doing something wrong or should I just ignore the warning since everything is working great? I am using 2nd version, and here the code I have:

    componentDidMount() {           
    AdMobRewarded.setAdUnitID('XXX');
  
    AdMobRewarded.addEventListener('rewarded',
      (reward) => console.log('AdMobRewarded => rewarded', reward)
    ); 
    AdMobRewarded.addEventListener('adLoaded',
      () => console.log('AdMobRewarded => adLoaded')
    );
    AdMobRewarded.addEventListener('adFailedToLoad',
      (error) => console.warn(error)
    );
    AdMobRewarded.addEventListener('adOpened',
      () => console.log('AdMobRewarded => adOpened')
    );
    AdMobRewarded.addEventListener('videoStarted',
      () => console.log('AdMobRewarded => videoStarted')
    );
    AdMobRewarded.addEventListener('adClosed',
      () => {
        console.log('AdMobRewarded => adClosed');
        AdMobRewarded.requestAd().catch(error => console.warn(error));
      }
    );
    AdMobRewarded.addEventListener('adLeftApplication',
      () => console.log('AdMobRewarded => adLeftApplication')
    );

    AdMobRewarded.requestAd().catch(error => console.warn(error));
    }
    
    componentWillUnmount() {
    AdMobRewarded.removeAllListeners();
  }

  showRewarded() {
    AdMobRewarded.showAd().catch(error => console.warn(error));
  } 

....

<Button
              onPress={() => this.showRewarded()
               }
            />

bvv218 avatar Jan 17 '18 07:01 bvv218

If you are using an emulator, close the app and kill it. I hope this should work.

saravanakumargn avatar Jan 28 '18 03:01 saravanakumargn

@saravanakumargn I am using physical device and it happens every time.

bvv218 avatar Jan 29 '18 17:01 bvv218

I got the same error and after removing catch error handle its working fine. Please let me know if anyone got the proper solution. AdMobRewarded.requestAd().catch(error => console.warn(error));

saravanakumargn avatar Jan 30 '18 08:01 saravanakumargn

Does the ad load for you? When I get "Error: Ad is already loaded.", Ad doesn't want to load and I get only this warning.

bvv218 avatar Jan 31 '18 20:01 bvv218

try this way: AdMobRewarded.requestAd() .then(() => AdMobRewarded.showAd()) .catch(error => console.warn(error))

kyrylenko avatar Feb 01 '18 19:02 kyrylenko

same here. any solutions so far?

umut885 avatar Oct 28 '18 23:10 umut885

Any update? this open the app twice. For me the action: "AdMobRewarded" works good But the problems are in: "AdMobInterstitial" and "Banner"

roysG avatar Dec 29 '18 18:12 roysG

AdMobRewarded.requestAd().then(() => AdMobRewarded.showAd())

This will work! 👍🏻

abhisheq6u avatar Jan 14 '20 19:01 abhisheq6u

Yes i was also facing the same problem but you can fix this issue by just copy-paste the following code componentWillUnmount() { AdMobRewarded.removeAllListeners(); }

in react native

heyakhil avatar Aug 23 '20 13:08 heyakhil

It only shows the Ad 1 time if i skipped/closed the Ad via "adClosed" event.

the error is Error: Ad is already loaded.

tayfunyasar avatar Nov 10 '20 20:11 tayfunyasar

Go to AdMobRewarded class in library folder in android folder and remove the following lines with red doodles. IMG_20210630_003249.jpg

Shasikhan avatar Jun 29 '21 19:06 Shasikhan

await AdMobInterstitial.setAdUnitID(adUnitID.android.interstitial); // Test ID, Replace with your-admob-unit-id await AdMobInterstitial.requestAdAsync({ servePersonalizedAds: true }); await AdMobInterstitial.showAdAsync();

// ad reloaded setTimeout(() => { AdMobInterstitial.dismissAdAsync(); }, 1000);

realmojo avatar Jul 26 '22 03:07 realmojo

AdMobInterstitial.setAdUnitID(adInterstitialUnitID); AdMobInterstitial.requestAdAsync({ servePersonalizedAds: true }) .then(async () => { await AdMobInterstitial.showAdAsync(); setTimeout(() => { //Here Write your code after user seen ad }, 3000); setLoading(false); }) .catch((error) => console.log(error)) .finally(() => { setTimeout(() => { AdMobInterstitial.dismissAdAsync(); }, 1000); });

McGwery avatar Nov 27 '22 12:11 McGwery