Osmbonuspack教程,道路管理员抛出错误

时间:2018-02-02 18:13:46

标签: android osmdroid

我最近开始考虑使用osmbonuspack,我开始使用教程0并使其工作,教程1你好路由世界我试图使用教程代码和osmbonuspacktuto下github上提供的代码。但我一直得到同样的错误。错误是;

" java.lang.NoClassDefFoundError:解析失败:Lokhttp3 / Request $ Builder;"

在线;

道路= roadManager.getRoad(wayPoints);

在搜索错误时,我看到了类似的错误,但是有了不同的@ aar&s,我看到人们因为等级依赖性而说它了吗?

这里的任何帮助都会很棒,这是我目前的代码;

Java Class;

protected void onCreate(Bundle savedInstanceState){         super.onCreate(savedInstanceState);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    Context ctx = getApplicationContext();
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
    setContentView(R.layout.activity_new_map);

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }

    map = (MapView) findViewById(R.id.map11);

    map.setTileSource(TileSourceFactory.MAPNIK);

    map.setBuiltInZoomControls(true);
    map.setMultiTouchControls(true);

    GeoPoint startPoint = new GeoPoint(48.13,-1.63);

    IMapController mapController = map.getController();
    mapController.setZoom(9);
    mapController.setCenter(startPoint);

    Marker starterMarker = new Marker(map);

    starterMarker.setPosition(startPoint);

    starterMarker.setAnchor(Marker.ANCHOR_CENTER,Marker.ANCHOR_BOTTOM);

    map.getOverlays().add(starterMarker);

    map.invalidate();

    starterMarker.setIcon(getResources().getDrawable(R.drawable.bonuspack_bubble));
    starterMarker.setTitle("Start Point");

    RoadManager roadManager = new OSRMRoadManager(this);

    ArrayList<GeoPoint> wayPoints = new ArrayList<GeoPoint>();

    wayPoints.add(startPoint);
    GeoPoint endPoint = new GeoPoint(48.4,-1.9);
    wayPoints.add(endPoint);

    Road road = roadManager.getRoad(wayPoints);

    if (road.mStatus !=  Road.STATUS_OK){
        Toast.makeText(this, "Error when loading road", Toast.LENGTH_LONG).show();
    }

    Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
    map.getOverlays().add(roadOverlay);




}

摇篮;

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'org.osmdroid:osmdroid-android:5.6.5@aar'
    implementation 'org.slf4j:slf4j-api:1.7.7@jar'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation project(':osmbonuspack_6.4')
}

1 个答案:

答案 0 :(得分:0)

自己搞清楚我在gradle中缺少一些依赖...