Crash: NPE: Attempt to read from field 'com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference
Summary
Had single crash from production inside the lib:
java.lang.NullPointerException: Attempt to read from field 'java.util.List com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference
Environment details
- Xiaomi Redmi 9A
- Android 10
implementation "com.google.maps.android:android-maps-utils-v3:2.0.3"
implementation "com.google.android.libraries.maps:maps:3.1.0-beta"
Stack trace
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:399)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by java.lang.NullPointerException: Attempt to read from field 'java.util.List com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference
at com.google.maps.android.clustering.algo.StaticCluster.remove(StaticCluster.java:48)
at com.google.maps.android.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.getClusters(NonHierarchicalDistanceBasedAlgorithm.java:212)
at com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.getClustersInternal(PreCachingAlgorithmDecorator.java:141)
at com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.getClusters(PreCachingAlgorithmDecorator.java:104)
at com.google.maps.android.clustering.algo.ScreenBasedAlgorithmAdapter.getClusters(ScreenBasedAlgorithmAdapter.java:71)
at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:312)
at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:306)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
@nostra13 Thanks for the report! Is this something you can reproduce? What was happening inside the app when the crash occurred?
@barbeau No, I couldn't reproduce it.
According to logs last 2 actions on map were:
- refresh markers on map
- remove all markers from map
So last action was com.google.maps.android.clustering.ClusterManager.removeItems(...) + cluster().
And probably (not sure) just before that markers were updated by ClusterManager.updateItem(...) or ClusterManager.addItems(...) + ClusterManager.cluster().
So possible calls before crash were:
clusterManager.updateItem(...) // maybe
clusterManager.updateItem(...) // maybe
clusterManager.addItems(...) // maybe
clusterManager.cluster()
clusterManager.removeItems(...)
clusterManager.cluster()
Not reproducible.