question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android ONLY: java.lang.IllegalStateException: PlatformView#getView() returned null, but an Android view reference was expected

See original GitHub issue

Bug report

Describe the bug Inline banner ad in a list cause crash on Android only.

Steps to reproduce

Steps to reproduce the behavior:

  1. Update dependency to 0.11.0+2 for google_mobile_ads & minSdk to 19 in (https://github.com/googlecodelabs/admob-inline-ads-in-flutter)
  2. Increase sample items x 3 which use for inline banner ad example
  3. Scroll down until ad goes out of viewport, scroll up again and had this crash below on Android ONLY:
E/flutter (12339): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.IllegalStateException: PlatformView#getView() returned null, but an Android view reference was expected.
E/flutter (12339): 	at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:710)
E/flutter (12339): 	at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:739)
E/flutter (12339): 	at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:957)
E/flutter (12339): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (12339): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (12339): 	at android.os.Looper.loop(Looper.java:206)
E/flutter (12339): 	at android.app.ActivityThread.main(ActivityThread.java:8419)
E/flutter (12339): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (12339): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
E/flutter (12339): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/flutter (12339): 
F/flutter (12339): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1196)] Check failed: CheckException(env). 
F/libc    (12339): Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 12339 (.admobinlineads), pid 12339 (.admobinlineads)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/x1sxx/x1s:11/RP1A.200720.012/G980FXXU5CUA3:user/release-keys'
Revision: '22'
ABI: 'arm64'
Timestamp: 2021-03-06 16:01:56+0300
pid: 12339, tid: 12339, name: .admobinlineads  >>> com.codelab.flutter.admobinlineads <<<
uid: 10371
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1196)] Check failed: CheckException(env). 
'
    x0  0000000000000000  x1  0000000000003033  x2  0000000000000006  x3  0000007fecb68210
    x4  0000007e1e62f000  x5  0000007e1e62f000  x6  0000007e1e62f000  x7  0000000003736aa0
    x8  00000000000000f0  x9  344ba72bcf5be43a  x10 0000000000000000  x11 ffffffc0fffffbdf
    x12 0000000000000001  x13 0000000000000074  x14 0000000000000000  x15 00006f5640eaf8be
    x16 0000007e174bac80  x17 0000007e1749cc50  x18 0000007e1e61e000  x19 0000000000003033
    x20 0000000000003033  x21 00000000ffffffff  x22 0000007be6bae010  x23 0000000000000000
    x24 0000000000000438  x25 00000000000000d8  x26 0000000000000001  x27 0000007fecb68510
    x28 0000000000000085  x29 0000007fecb68290
    lr  0000007e17450624  sp  0000007fecb681f0  pc  0000007e17450650  pst 0000000000000000
backtrace:
      #00 pc 000000000004e650  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: b6a050117a93689b5308931507900b87)
      #01 pc 0000000001288244  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #02 pc 00000000012792f4  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #03 pc 00000000012cb534  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #04 pc 00000000012be28c  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #05 pc 00000000012beb60  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #06 pc 00000000012bf4e0  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #07 pc 00000000012be5c4  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #08 pc 00000000012be398  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #09 pc 00000000012bf718  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #10 pc 0000000001288bbc  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #11 pc 000000000128dc7c  /data/app/~~E_A6gdfKtuyBjx_ve83yBg==/com.codelab.flutter.admobinlineads-n5uEz5IUmmkCJXhBAs3vHw==/lib/arm64/libflutter.so (BuildId: 9c542952e0ea7b7a4b9c9734eda4f117db4285aa)
      #12 pc 0000000000019da8  /system/lib64/libutils.so (android::Looper::pollInner(int)+916) (BuildId: 4e69b93bf70ed592f0029dbd1097529e)
      #13 pc 00000000000199ac  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: 4e69b93bf70ed592f0029dbd1097529e)
      #14 pc 00000000001187f4  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: 242a1c2f8c01c3530aee42ce4254ec53)
      #15 pc 000000000024f00c  /system/framework/arm64/boot-framework.oat (art_jni_trampoline+140) (BuildId: ba616edc5d43a5ad71e513e266d2e93e004cfa2e)
      #16 pc 00000000020019bc  /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.MessageQueue.next+204)
      #17 pc 0000000000134564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #18 pc 00000000001a9a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #19 pc 0000000000320d60  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #20 pc 000000000031708c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #21 pc 0000000000684870  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #22 pc 000000000012e814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #23 pc 000000000044caf2  /system/framework/framework.jar (offset 0x9cb000) (android.os.Looper.loop+154)
      #24 pc 000000000030e688  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.8133272982542804073)+268) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #25 pc 0000000000316678  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #26 pc 0000000000317a60  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, true>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1772) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #27 pc 0000000000178f40  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<true, false>(art::interpreter::SwitchImplContext*)+57848) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #28 pc 00000000001407d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #29 pc 00000000001cd564  /system/framework/framework.jar (android.app.ActivityThread.main)
      #30 pc 000000000030e790  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.8133272982542804073)+532) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #31 pc 00000000006732f4  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #32 pc 000000000013dff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #33 pc 00000000001347e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #34 pc 00000000001a9a94  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #35 pc 000000000055d2a0  /apex/com.android.art/lib64/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1364) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #36 pc 00000000004dc60c  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #37 pc 000000000008a6f4  /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+180) (BuildId: cf3195be2d1e729ad27299071d73c22f0d849b44)
      #38 pc 0000000000134564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #39 pc 00000000001a9a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #40 pc 0000000000320d60  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #41 pc 000000000031708c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #42 pc 0000000000684870  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #43 pc 000000000012e814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #44 pc 0000000000236df6  /system/framework/framework.jar (offset 0x1c0c000) (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+22)
      #45 pc 000000000030e688  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.8133272982542804073)+268) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #46 pc 00000000006732f4  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #47 pc 000000000013dff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #48 pc 0000000000afbfac  /system/framework/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2444) (BuildId: ba616edc5d43a5ad71e513e266d2e93e004cfa2e)
      #49 pc 00000000001347e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #50 pc 00000000001a9a94  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #51 pc 000000000055bcdc  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+448) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #52 pc 000000000055c190  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #53 pc 0000000000440b94  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+656) (BuildId: 1e59dbd15c62f521119299bf54dfe884)
      #54 pc 000000000009d424  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124) (BuildId: 242a1c2f8c01c3530aee42ce4254ec53)
      #55 pc 00000000000a5244  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+848) (BuildId: 242a1c2f8c01c3530aee42ce4254ec53)
      #56 pc 0000000000003594  /system/bin/app_process64 (main+1356) (BuildId: 1b1b967ddfe0761f978fc1b2bd9ea55a)
      #57 pc 0000000000049a38  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: b6a050117a93689b5308931507900b87)
Lost connection to device.

`

Expected behavior

No crash.


Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
PASTE OUTPUT INSIDE HERE

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
PASTE OUTPUT INSIDE HERE

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:20

github_iconTop GitHub Comments

8reactions
franciscocpgcommented, Apr 8, 2021

In my case, I was able to fix it by removing the call to ad.dispose() at the onAdFailedToLoad listener.

3reactions
songyiYucommented, Mar 25, 2021

@jjliu15 I still get this error in 0.11.0+3. Android sdk version is 4.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unhandled Exception: PlatformException(error, java.lang ...
In Android Studio, Go to file => settings => System Settings => Android SDk to confirm you have the SDK installed for the...
Read more >
View - Android Developers
These methods both return the location of the view relative to its parent. For instance, when getLeft() returns 20, that means the view...
Read more >
Menus - Android Developers
Menus are a common user interface component in many types of applications. To provide a familiar and consistent user experience, ...
Read more >
Use common Kotlin patterns with Android
This implies that when you obtain an instance of a class, you can immediately reference any of its accessible properties. The View objects...
Read more >
PreferenceFragmentCompat - Android Developers
You can define a preference hierarchy as an XML resource, or you can build a hierarchy in code. In both cases you need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found