我创建了一个小项目来显示我在 MapBox 导航库中遇到的错误。
我想知道它是来自生命周期中的一个元素还是直接使用的SDK?
困难在于我希望片段在每次到达时重新启动导航服务。
链接项目: https ://github.com/gonzalt03/mapbox-navigation-android-fragment-test-app
02-05 16:17:47.353 24931-24931/com.company.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.company.myapplication, PID: 24931
java.lang.RuntimeException: Unable to resume activity {com.company.myapplication/com.company.myapplication.MainActivity}: java.lang.RuntimeException: Failed to call observer method
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3848)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3889)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6836)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.RuntimeException: Failed to call observer method
at android.arch.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:225)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:193)
at android.arch.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:184)
at android.arch.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:353)
at android.arch.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:291)
at android.arch.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:331)
at android.arch.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:137)
at android.arch.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:123)
at android.arch.lifecycle.ReportFragment.dispatch(ReportFragment.java:121)
at android.arch.lifecycle.ReportFragment.onStart(ReportFragment.java:81)
at android.app.Fragment.performStart(Fragment.java:2378)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1027)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:2048)
at android.app.FragmentController.dispatchStart(FragmentController.java:188)
at android.app.Activity.performStart(Activity.java:6978)
at android.app.Activity.performRestart(Activity.java:7088)
at android.app.Activity.performResume(Activity.java:7093)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3825)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3889)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6836)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayer.setLayerVisibility(LocationLayer.java:76)
at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin.setLocationLayerEnabled(LocationLayerPlugin.java:139)
at com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin.onStart(LocationLayerPlugin.java:265)...