firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.68k stars 3.97k forks source link

[firebase_admob] Use AndroidView the bug that occurs when ad is in setstate. #1441

Closed a27919478 closed 3 years ago

a27919478 commented 4 years ago

Using AndroidView causes native ads or banner ads to crash. When using setstate. Due to the high probability of occurrence, please reply as soon as possible. image

Crash log:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.Display.getSize(android.graphics.Point)' on a null object reference
       at org.chromium.ui.display.DisplayAndroid.updateFromDisplay(DisplayAndroid.java:133)
       at org.chromium.ui.display.DisplayAndroidManager$DisplayListenerBackendImpl.onDisplayChanged(DisplayAndroidManager.java:169)
       at android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate.handleMessage(DisplayManagerGlobal.java:540)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.Display.getSize(android.graphics.Point)' on a null object reference
       at org.chromium.ui.display.DisplayAndroid.updateFromDisplay(DisplayAndroid.java:280)
       at org.chromium.ui.display.DisplayAndroidManager$DisplayListenerBackendImpl.onDisplayChanged(DisplayAndroidManager.java:176)
       at android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate.handleMessage(DisplayManagerGlobal.java:786)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:7406)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

My flutter version:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G95, locale
    zh-Hans-HK)

[!] Android toolchain - develop for Android devices (Android SDK version
    29.0.0-rc1)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[✓] Connected device (1 available)
iapicca commented 4 years ago

Hi @a27919478 could you please provide could post a minimal code sample to reproduce the problem Thank you

a27919478 commented 4 years ago

@iapicca Because I can't reproduce the problem, but I suspect that this problem is related to the previous use of WebView by flutter. It's a little bit like this: https://github.com/flutter/flutter/issues/30420

russellwheatley commented 3 years ago

The firebase_admob plugin will be deprecated in April 2021 in favor of Google Mobile Ads SDK for Flutter. Google Mobile Ads SDK for Flutter is a new Flutter plugin that supports more Ads formats than firebase_admob does. Google Mobile Ads SDK for Flutter currently supports loading and displaying banner, interstitial (full-screen), native ads, and rewarded video ads across AdMob and AdManager. It also supports displaying banner and native ads as Widgets as opposed to being overlayed over all app content. We're now recommending projects currently using firebase_admob migrate to Google Mobile Ads SDK for Flutter following the instructions outlined here. Issues with migrating or with using the new package should now be raised over on the Google Mobile Ads SDK for Flutter repository.