Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Google maps crash on resize

In my use case, I need to make sure that my map can resize dynamically without crashing, you may suggest using resizeToAvoidBottomPadding, but my problem is beyond that, for example, my app crashes if I'm using facebook messanger chat head and open it's keyboard (which made the app resize forcing the map to resize hence the crash)

the following code is inside a sub-route (inside a route containing a bottom tab bar, so the following code is inside one of the bar's buttons)

@override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        GoogleMap(
          onMapCreated: _onMapCreated,
          mapType: MapType.normal,
          initialCameraPosition: CameraPosition(
            target: LatLng(30, 40),
            zoom: 11,
          ),
          onCameraMove: (pos) {
            setState(() {
              // do something
            });
          },
          onCameraIdle: () {
            setState(() {
              // do something
            });
          },
        ),
        TextField(),
      ],
    );
  }

Edit: this is the error message I get in the console:

E/flutter (16068): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.AbstractMethodError: abstract method "void io.flutter.plugin.platform.PlatformView.onInputConnectionLocked()"
E/flutter (16068):  at io.flutter.plugin.platform.VirtualDisplayController.onInputConnectionLocked(VirtualDisplayController.java:166)
E/flutter (16068):  at io.flutter.plugin.platform.PlatformViewsController.lockInputConnection(PlatformViewsController.java:370)
E/flutter (16068):  at io.flutter.plugin.platform.PlatformViewsController.access$1000(PlatformViewsController.java:36)
E/flutter (16068):  at io.flutter.plugin.platform.PlatformViewsController$1.resizePlatformView(PlatformViewsController.java:165)
E/flutter (16068):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.resize(PlatformViewsChannel.java:120)
E/flutter (16068):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:57)
E/flutter (16068):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/flutter (16068):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/flutter (16068):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/flutter (16068):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (16068):  at android.os.MessageQueue.next(MessageQueue.java:323)
E/flutter (16068):  at android.os.Looper.loop(Looper.java:136)
E/flutter (16068):  at android.app.ActivityThread.main(ActivityThread.java:6776)
E/flutter (16068):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (16068):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
E/flutter (16068):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
E/flutter (16068):  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
E/flutter (16068): 
F/flutter (16068): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env). 
F/libc    (16068): Fatal signal 6 (SIGABRT), code -6 in tid 16068 (m.dm.dm_testing)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/a7xeltexx/a7xelte:7.0/NRD90M/A710FXXU2CQG4:user/release-keys'
Revision: '3'
ABI: 'arm'
pid: 16068, tid: 16068, name: m.dm.dm_testing  >>> com.dm.dm_testing <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env). 
'
    r0 00000000  r1 00003ec4  r2 00000006  r3 00000008
    r4 ec60358c  r5 00000006  r6 ec603534  r7 0000010c
    r8 ffcc802c  r9 db59415c  sl 00000032  fp db594110
    ip 0000000b  sp ffcc7f08  lr ea8f04c7  pc ea8f2d30  cpsr 000e0010
backtrace:
    #00 pc 0004ad30  /system/lib/libc.so (tgkill+12)
    #01 pc 000484c3  /system/lib/libc.so (pthread_kill+34)
    #02 pc 0001dd99  /system/lib/libc.so (raise+10)
    #03 pc 00019521  /system/lib/libc.so (__libc_android_abort+34)
    #04 pc 00017160  /system/lib/libc.so (abort+4)
    #05 pc 00fa7b9f  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #06 pc 00f9dde1  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #07 pc 00f9cad7  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #08 pc 00fcfb83  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #09 pc 00fa81f5  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #10 pc 00fab943  /data/app/com.dm.dm_testing-1/lib/arm/libflutter.so (offset 0xf99000)
    #11 pc 00011e77  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+614)
    #12 pc 00011b83  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+26)
    #13 pc 00097325  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)
    #14 pc 7594bd55  /data/dalvik-cache/arm/system@[email protected] (offset 0x38c0000)
Lost connection to device.

thanks for the help.

like image 247
Basel Abuhadrous Avatar asked Mar 21 '26 00:03

Basel Abuhadrous


2 Answers

This is a bug related to changes in Gradle 3.5.0. It's currently fixed in the Flutter master channel.

If you want to work around it now, add android.enableDexingArtifactTransform=false to your gradle.properties file to disable the new Gradle changes.

like image 192
mklim Avatar answered Mar 24 '26 03:03

mklim


  1. Wrap your Stack with Expanded widget
  2. Wrap Expanded Widget with Column

You are done...

like image 38
Arun R. Prajapati Avatar answered Mar 24 '26 01:03

Arun R. Prajapati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!