2017-08-08 42 views
0

我試圖用mapsforge開始我的第一個項目。所以,我這樣做,改變應用程序/的build.gradleMapsforge InternalRenderTheme缺失錯誤

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 
    compile 'org.mapsforge:mapsforge-map-android:0.8.0' 
    compile 'com.caverock:androidsvg:1.2.2-beta-1' 
    compile('org.mapsforge:mapsforge-map-android-extras:0.8.0') { 
     transitive = false 
    } 
} 

然後,我把代碼從這裏:Code Example App。 這是我的MainActivity

package kn.com.ff_map; 

import android.os.Bundle; 

import android.app.Activity; 
import android.os.Environment; 

import org.mapsforge.core.model.LatLong; 
import org.mapsforge.map.android.graphics.AndroidGraphicFactory; 
import org.mapsforge.map.android.util.AndroidUtil; 
import org.mapsforge.map.android.view.MapView; 
import org.mapsforge.map.datastore.MapDataStore; 
import org.mapsforge.map.layer.cache.TileCache; 
import org.mapsforge.map.layer.renderer.TileRendererLayer; 
import org.mapsforge.map.reader.MapFile; 
import org.mapsforge.map.rendertheme.InternalRenderTheme; 

import java.io.File; 

public class MainActivity extends Activity { 
    // name of the map file in the external storage 
    private static final String MAP_FILE = "berlin.map"; 

    private MapView mapView; 

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

     AndroidGraphicFactory.createInstance(this.getApplication()); 

     this.mapView = new MapView(this); 
     setContentView(this.mapView); 

     this.mapView.setClickable(true); 
     this.mapView.getMapScaleBar().setVisible(true); 
     this.mapView.setBuiltInZoomControls(true); 
     this.mapView.setZoomLevelMin((byte) 10); 
     this.mapView.setZoomLevelMax((byte) 20); 

     // create a tile cache of suitable size 
     TileCache tileCache = AndroidUtil.createTileCache(this, "mapcache", 
       mapView.getModel().displayModel.getTileSize(), 1f, 
       this.mapView.getModel().frameBufferModel.getOverdrawFactor()); 

     // tile renderer layer using internal render theme 
     MapDataStore mapDataStore = new MapFile(new File(Environment.getExternalStorageDirectory(), MAP_FILE)); 
     TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, 
       this.mapView.getModel().mapViewPosition, AndroidGraphicFactory.INSTANCE); 
     tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT); 

     // only once a layer is associated with a mapView the rendering starts 
     this.mapView.getLayerManager().getLayers().add(tileRendererLayer); 

     this.mapView.setCenter(new LatLong(52.517037, 13.38886)); 
     this.mapView.setZoomLevel((byte) 12); 
    } 

    @Override 
    protected void onDestroy() { 
     this.mapView.destroyAll(); 
     AndroidGraphicFactory.clearResourceMemoryCache(); 
     super.onDestroy(); 
    } 
} 

我總是得到錯誤,

Error:(16, 37) error: cannot find symbol class InternalRenderTheme

Error:(50, 45) error: cannot find symbol variable InternalRenderTheme

所以這是我第一次嘗試一個lib在我的項目整合。我只是這樣做,我沒有下載任何東西或從回購中複製任何東西。我必須下載mapforge或者這個錯誤是什麼意思?

回答

1

我的決定是加入build.gragle的應用

compile 'org.mapsforge:mapsforge-themes:0.8.0'