Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps crash: java.lang.NullPointerException: Attempt to read from null array

I see a lot of following crashes in Crashlytics:

Fatal Exception: java.lang.NullPointerException: Attempt to read from null array
   at java.util.ArrayList.get(ArrayList.java:310)
   at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.g.a(g.java:56)
   at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.a(ao.java:91)
   at com.google.maps.api.android.lib6.gmm6.store.fetch.i.a(i.java:99)
   at com.google.maps.api.android.lib6.gmm6.store.fetch.f.a(f.java:3)
   at com.google.maps.api.android.lib6.gmm6.store.j.a(j.java:19)
   at com.google.maps.api.android.lib6.gmm6.store.k.a(k.java:96)
   at com.google.maps.api.android.lib6.gmm6.store.f.handleMessage(f.java:71)
   at android.os.Handler.dispatchMessage(Handler.java:111)
   at android.os.Looper.loop(Looper.java:194)
   at com.google.maps.api.android.lib6.gmm6.store.k.run(k.java:126)
   at com.google.maps.api.android.lib6.gmm6.store.ab.run(ab.java:12)

All of them happen on Android 5, mostly on Lenovo devices.

The map is loaded in SupportMapFragment.

Dependencies (current latest):

com.google.android.gms:play-services-maps:17.0.0

com.google.maps.android:android-maps-utils:0.6.2

What could be the cause of this crash?

like image 402
Alexey Timokhin Avatar asked Dec 06 '19 08:12

Alexey Timokhin


2 Answers

Ok, so I opened a ticket on google issue tracker and a lot of people confirmed they were facing the same crash.

Seems like an internal bug ticket was created and the work is being done to resolve the issue on maps side. Also a temporary workaround was suggested in comments:

The workaround, that worked for me is to set maxZoomPreference on the map equal to 16 and to use 16 as zoom level in the calling of the newLatLngZoom method. It seems that the issue occurs only when you try to zoom more than 16 levels.

We implemented the suggested approach in our app and it indeed prevents the crash.

Upd:

According to Google the crash was fixed for future SDK versions.

Upon further checking, our Engineering Team was able to reproduce the problem and already fixed it in the latest SDK version.

like image 119
Yaroslav Avatar answered Nov 12 '22 05:11

Yaroslav


I faced with this problem on Lenovo TB3-710I (android 5.1). The workaround was disabling 3D model buildings.

googleMap.isBuildingsEnabled = false
like image 27
Timur Oksak Avatar answered Nov 12 '22 06:11

Timur Oksak