0

我正在编译 MBTilesOsmDroidExample https://github.com/djcoin/MBTilesOsmdroidExample 我收到以下错误。

mbtile 文件位于 assest 文件夹中。

11-21 12:29:29.693: E/Database(330): sqlite3_open_v2("/mnt/sdcard/military-bene-and-tacan-routes.db", &handle, 1, NULL) failed
11-21 12:29:29.693: D/AndroidRuntime(330): Shutting down VM
11-21 12:29:29.693: W/dalvikvm(330): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-21 12:29:29.723: E/AndroidRuntime(330): FATAL EXCEPTION: main
11-21 12:29:29.723: E/AndroidRuntime(330): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.tilespitter.mapboxtiles/org.tilespitter.mapboxtiles.MBTilesOsmdroidExample}: android.database.sqlite.SQLiteException: unable to open database file
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.os.Looper.loop(Looper.java:123)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-21 12:29:29.723: E/AndroidRuntime(330):  at java.lang.reflect.Method.invokeNative(Native Method)
11-21 12:29:29.723: E/AndroidRuntime(330):  at java.lang.reflect.Method.invoke(Method.java:507)
11-21 12:29:29.723: E/AndroidRuntime(330):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-21 12:29:29.723: E/AndroidRuntime(330):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-21 12:29:29.723: E/AndroidRuntime(330):  at dalvik.system.NativeStart.main(Native Method)
11-21 12:29:29.723: E/AndroidRuntime(330): Caused by: android.database.sqlite.SQLiteException: unable to open database file
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1849)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
11-21 12:29:29.723: E/AndroidRuntime(330):  at org.osmdroid.tileprovider.modules.MBTilesFileArchive.getDatabaseFileArchive(MBTilesFileArchive.java:43)
11-21 12:29:29.723: E/AndroidRuntime(330):  at org.tilespitter.mapboxtiles.MBTilesOsmdroidExample.mapBeginConfig(MBTilesOsmdroidExample.java:55)
11-21 12:29:29.723: E/AndroidRuntime(330):  at org.tilespitter.mapboxtiles.MBTilesOsmdroidExample.onCreate(MBTilesOsmdroidExample.java:43)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-21 12:29:29.723: E/AndroidRuntime(330):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-21 12:29:29.723: E/AndroidRuntime(330):  ... 11 more

这是加载资产的代码。除了文件名之外,我没有更改代码。

    private void mapBeginConfig(){
    mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
    SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this);

    File f = new File(Environment.getExternalStorageDirectory(), "military-bene-and-tacan-routes.db"); //change from map.mbtiles

    IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };        
    MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);

    mProvider = new MapTileProviderArray(MBTILESRENDER, null, 
            new MapTileModuleProviderBase[]{ moduleProvider }
    );

    this.mOsmv = new MapView(this, 256, mResourceProxy, mProvider);

}

我的问题是否有人可以检查为什么无法加载 MBtiles 文件资产文件夹?

4

2 回答 2

0

Environment.getExternalStorageDirectory(), "military-bene-and-tacan-routes.db"

该声明指的是 sdcard 而不是资产。将您的 .db 文件放在 sdcard 上,它将运行

于 2014-11-27T05:00:39.660 回答
0

OSMDroid 仅处理资产文件夹中的原始图像。数据库必须位于 /sdcard/osmdroid 或设备上的其他位置。为了加载切片,ITileSource名称必须与数据库中切片图层的名称匹配。您可以编写采用现有的数据库加载器来删除该检查,这可能会为您简化事情

于 2015-10-19T11:08:45.507 回答