我有存储 key ,但 mapbox 还在说
E/Mbgl-FileSource: Failed to read the storage key:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Bundle.getBoolean(java.lang.String, boolean)' on a null object reference
at com.mapbox.mapboxsdk.storage.FileSource.getCachePath(FileSource.java:88)
at com.mapbox.mapboxsdk.storage.FileSource$FileDirsPathsTask.doInBackground(FileSource.java:165)
at com.mapbox.mapboxsdk.storage.FileSource$FileDirsPathsTask.doInBackground(FileSource.java:155)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
我在调用 MapView.onStart()
时也遇到了错误。
是不是因为我用的是free token?
此外,在调用 Log.d("app", Mapbox.getAccessToken());
我的另一个问题是,当我使用这段代码开始导航时:
NavigationLauncherOptions options = NavigationLauncherOptions.builder().origin(origin).destination(dest).shouldSimulateRoute(true).build();
NavigationLauncher.startNavigation(this, options);
Navigation 中的 map 不会显示,它只是一个带有 UI 的蓝色空白背景,可能是因为无法读取 key 。但这不能成为原因,因为 Mapbox.getAccessToken()
正在返回我的正确 token 。我现在真的很困惑。
最佳答案
FWIW,我有完全相同的错误,对我来说,结果是我在尝试找到我的 map View 之前没有设置内容 View 。
setContentView(R.layout.activity_main);
mapView = findViewById(R.id.mapView);
关于Mapbox 读取存储 key 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52404593/