![](/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.