capacitor-community / admob

Community plugin for using Google AdMob
MIT License
205 stars 66 forks source link

App crashing after showInterstitial on Android #313

Closed kisimediaDE closed 3 months ago

kisimediaDE commented 3 months ago

Describe the bug I have an app that is showing an Interstitial with AdMob.showInterstitial(); After the Ad is shown completely and the user is closing the Ad the app is crashing. Error message from Android Studio:

FATAL EXCEPTION: main Process: xx.xxxxxxxx.xxxxxxxxxx, PID: 20558 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.ads.AdView.loadAd(com.google.android.gms.ads.AdRequest)' on a null object reference at com.getcapacitor.community.admob.banner.BannerExecutor.lambda$updateExistingAdView$3(BannerExecutor.java:218) at com.getcapacitor.community.admob.banner.BannerExecutor.$r8$lambda$rG8pevl4TYjNjEUjyIXkgzJ2UsA(Unknown Source:0) at com.getcapacitor.community.admob.banner.BannerExecutor$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:233) at android.os.Looper.loop(Looper.java:334) at android.app.ActivityThread.main(ActivityThread.java:8396) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

Desktop (please complete the following information):

Smartphone (please complete the following information):

distante commented 3 months ago

You are calling a show banner without preparing it.

kisimediaDE commented 3 months ago

Hey thanks for your answer. For some reason I was so blind yesterday. Trying different things for hours. And today after your message I found it immediately.

For some reason I have an listener for the appStateChange in my app.component (App.addListener('appStateChange')) Where I remove the banner. And this listener is called when the Interstitial gets active.

I have to figure out why I have this listener. but it's working now. thanks! 👍