![](/img/trans.png)
[英]Android java.lang.NullPointerException: Attempt to get length of null array
[英]Google maps api gets Fatal Exception: java.lang.NullPointerException: Attempt to get length of null array
有时在我的 map 活动中,有 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)
我不知道可能是什么问题,有时它可以工作,有时它会给我这个错误,尤其是在我的 LG g6 上。 我找了几天,一无所获。 谁能指出我可能是什么问题?
当我使用 map 离开屏幕并过快返回时,我的 flutter 应用程序上显示了相同的错误。 我认为这个问题在这里讨论:
https://issuehint.com/issue/flutter/flutter/105584
他们提到了 Flutter 3 的问题,并建议返回到 Flutter 2.10。
**编辑:Github 中有一个未解决的问题: https://github.com/flutter/flutter/issues/105965
一位用户说:
“到目前为止,我唯一能想到的就是在屏幕上使用 GoogleMap 小部件添加一个延迟到 Navigator.pop + 拒绝用户在此期间做任何事情。”
Future<void> _delayedPop(BuildContext context) async {
unawaited(
Navigator.of(context, rootNavigator: true).push(
PageRouteBuilder(
pageBuilder: (_, __, ___) => WillPopScope(
onWillPop: () async => false,
child: Scaffold(
backgroundColor: Colors.transparent,
body: const Center(
child: CircularProgressIndicator.adaptive(),
),
),
),
transitionDuration: Duration.zero,
barrierDismissible: false,
barrierColor: Colors.black45,
opaque: false,
),
),
);
await Future.delayed(const Duration(seconds: 1));
Navigator.of(context)
..pop()
..pop();
}
我不确定这是你的问题,因为你在 2 年前发布了这个帖子,但也许它会帮助其他人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.