Nullpointerexception at Mapbox.getInstance method
Platform: 4/5/6 Mapbox SDK version: 5.1.0
Hey there, we are experiencing this NPE on some devices when calling Mapbox.getInstance(this, "OUR_TOKEN"); in Application class. Please help, thank you.
Stack trace:
Fatal Exception: java.lang.RuntimeException: Unable to create application ninjavan.swiftninja.NVDriverApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] android.content.pm.PackageManager.getPackagesForUid(int)' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4987)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5769)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] android.content.pm.PackageManager.getPackagesForUid(int)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1605)
at android.os.Parcel.readException(Parcel.java:1552)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:885)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:469)
at com.mapzen.android.lost.internal.FusionEngine.enablePassive(FusionEngine.java:120)
at com.mapzen.android.lost.internal.FusionEngine.enable(FusionEngine.java:82)
at com.mapzen.android.lost.internal.LocationEngine.setRequest(LocationEngine.java:36)
at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.requestLocationUpdates(FusedLocationProviderApiImpl.java:50)
at com.mapbox.mapboxsdk.location.LocationSource.requestLocationUpdates(LocationSource.java:123)
at com.mapbox.services.android.telemetry.MapboxTelemetry.onConnected(MapboxTelemetry.java:375)
at com.mapbox.mapboxsdk.location.LocationSource.activate(LocationSource.java:57)
at com.mapbox.services.android.telemetry.MapboxTelemetry.registerLocationUpdates(MapboxTelemetry.java:370)
at com.mapbox.services.android.telemetry.MapboxTelemetry.setTelemetryEnabled(MapboxTelemetry.java:312)
at com.mapbox.services.android.telemetry.MapboxTelemetry.loadUserPreferences(MapboxTelemetry.java:282)
at com.mapbox.services.android.telemetry.MapboxTelemetry.initialize(MapboxTelemetry.java:134)
at com.mapbox.services.android.telemetry.MapboxTelemetry.initialize(MapboxTelemetry.java:103)
at com.mapbox.mapboxsdk.Mapbox.getInstance(Mapbox.java:51)
at ninjavan.swiftninja.NVDriverApplication.onCreate(NVDriverApplication.java:64)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1019)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4984)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1554)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5769)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
This crash seems to stem from LOST, we don't call getPackagesForUid() in our code. Which version of LOST is added to your app? You can verify this with ./gradlew :module_name:dependencies and search for instances of lost.
Note that we downgraded to LOST 1.1.1 in v5.1.0
We are not using any LOST in our app, in fact this is the first time I heard about LOST.
LOST can be pulled in from other dependencies, are you using any other mapbox dependencies? Do you have a bit more information on how to reproduce this? Are you able to reproduce this on demand? Are specific devices affected?
Negative, no other mapbox dependencies added. We do have a few Google libraries added as below:
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
Got this report from Crashlytics, not reproducible so far and it happens on random devices, e.g. Sony, HTC, Lenovo and so on.
I am seeing only Mapbox has LOST dependency under the tree hierarchy in my project, after verifying with ./gradlew :module_name:dependencies command.
@tobrun We're seeing the same issue on our end, we aren't using our own Lost dependency.
For more info, i've shared the crash log: http://crashes.to/s/f17652df847
Looks to be mostly 6.0 for us.
Let me know if I should create an issue over at Lost instead
This is going be catched with https://github.com/mapbox/mapbox-gl-native/pull/9658. We are working on a new version of telemetry that will take in account this issue.