tom*_*sky 5 java android google-maps
有时在我的地图活动中有 50% 的时间会出现此错误:
Fatal Exception: java.lang.NullPointerException: Attempt to get length of null array
at java.nio.ByteBufferAsIntBuffer.put(ByteBufferAsIntBuffer.java:122)
at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.o.e(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):20)
at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.o.d(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):36)
at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.a.a(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):66)
at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.a(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):227)
at com.google.maps.api.android.lib6.gmm6.vector.cl.a(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):274)
at com.google.maps.api.android.lib6.gmm6.vector.bz.a(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):359)
at com.google.maps.api.android.lib6.gmm6.vector.bg.run(:com.google.android.gms.dynamite_mapsdynamite@19420048@19.4.20 (040400-271418971):85)
Run Code Online (Sandbox Code Playgroud)
我不知道可能是什么问题,有时它可以工作,有时它会给我那个错误,尤其是在我的 LG g6 上。我搜索了几天,一无所获。有人可以指出我可能是什么问题吗?
根据以下评论,尝试一下:
添加。google_maps_flutter_android: '>=2.4.15'
pubspec.yaml
然后在运行您的应用程序之前,调用以下位置main()
:
if (Platform.isAndroid) {
await GoogleMapsFlutterAndroid().initializeWithRenderer(AndroidMapRenderer.latest);
}
Run Code Online (Sandbox Code Playgroud)
希望这能解决问题。
当我离开带有地图的屏幕并太快返回时,我的 flutter 应用程序上显示了相同的错误。我认为这个问题在这里讨论:
\nhttps://issuehint.com/issue/flutter/flutter/105584
\n他们提到了 Flutter 3 的问题并建议回到 Flutter 2.10。
\n**编辑:Github 中有一个未解决的问题:https://github.com/flutter/flutter/issues/105965
\n一位用户说:
\n“到目前为止,我唯一能想到的就是使用 GoogleMap 小部件 \xe2\x80\x94 在屏幕上添加 \xe2\x80\x94 延迟 Navigator.pop + 拒绝用户同时执行任何操作”。
\nFuture<void> _delayedPop(BuildContext context) async {\n unawaited(\n Navigator.of(context, rootNavigator: true).push(\n PageRouteBuilder(\n pageBuilder: (_, __, ___) => WillPopScope(\n onWillPop: () async => false,\n child: Scaffold(\n backgroundColor: Colors.transparent,\n body: const Center(\n child: CircularProgressIndicator.adaptive(),\n ),\n ),\n ),\n transitionDuration: Duration.zero,\n barrierDismissible: false,\n barrierColor: Colors.black45,\n opaque: false,\n ),\n ),\n );\n await Future.delayed(const Duration(seconds: 1));\n Navigator.of(context)\n ..pop()\n ..pop();\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n自从您两年前发布此帖子以来,我不确定这是您的情况的问题,但也许它会对其他人有所帮助!
\n