下载图块时发生错误:android中mapbox的空文件

时间:2018-12-11 09:27:50

标签: android routes mapbox

我是新手,正在编写一个功能,可以下载Mapbox的OfflineRoute磁贴以供离线使用。我已按照https://www.mapbox.com/android-docs/navigation/overview/offline-routing/的说明进行操作,但收到错误消息“ 共享下载时出错:空文件”。我试图找出,但不知道此错误的原因。 我用

'com.mapbox.mapboxsdk: mapbox-android-sdk: 6.7.2'
'com.mapbox.mapboxsdk: mapbox-android-navigation-ui: 0.24.1'
'com.mapbox.mapboxsdk: mapbox-android-plugin-offline: 0.2.0'
'com.mapbox.mapboxsdk: mapbox-android-navigation: 0.24.1'

Android SDK 22, 在android虚拟机SDK 26上测试。 有人能帮我吗? 非常感谢您的帮助。

private File offlinepath3;
private BoundingBox boundingbox1;
private String versionRouteOff = null;
private  String token = "MapBoxKey";
    private void downOfflineRouteTiles(){
            boundingbox1 = BoundingBox.fromLngLats(-80.433727, 43.777139, -80.33727, 43.797139);
                offlineRouter1.fetchAvailableTileVersions(token, new OnTileVersionsFoundCallback() {
                    @Override
                    public void onVersionsFound(@NonNull List <String> availableVersions) {
                        versionRouteOff = availableVersions.get(1);

                        OfflineTiles.Builder builder = OfflineTiles.builder()
                                .accessToken(token)
                                .version(versionRouteOff)
                                .boundingBox(boundingbox1);

                        MapboxOfflineRouter offlineRouter23 = new MapboxOfflineRouter(offlinepath3.getAbsolutePath());
                        offlineRouter23.downloadTiles(builder.build(), new RouteTileDownloadListener() {

                            @Override
                            public void onError(@NonNull OfflineError error) {
                                Toast.makeText(Begin.this, error.getMessage(), Toast.LENGTH_SHORT).show();
                                Log.e(TAG,error.getMessage());
                            }

                            @Override
                            public void onProgressUpdate(int percent) {
                                Log.e(TAG,""+percent+"%");
                            }

                            @Override
                            public void onCompletion() {
                                Toast.makeText(Begin.this, "Completed", Toast.LENGTH_SHORT).show();
                            }
                        });
                    }

                    @Override
                    public void onError(@NonNull OfflineError error) {
                        Toast.makeText(Begin.this, "Cant get Version!", Toast.LENGTH_SHORT).show();
                        Log.e(TAG,"Error Version: "+error.getMessage());
                    }
                });
        }

0 个答案:

没有答案