因此,我試圖使用Android SQLite資產助手與我的應用程序預先打包數據庫,並且遇到了問題。這裏有一點點信息上手:Android SQLite資產助手錯誤
- 使用過Android Studio(gradle這個)
- 我已經修改build.grade包括
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
- 我有我的數據庫壓縮(workoutsDatabase.sqlite.zip)在我的src/main /資產/數據庫文件夾
我WorkoutsDatabaseHelper.java如下所示(對不起,壞的格式化,格式化今早愚蠢!)
import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; public class WorkoutsDatabaseHelper extends SQLiteAssetHelper {
//所有靜態變量 //數據庫版本 private static final int DATABASE_VERSION = 1;
// Database Name private static final String DATABASE_NAME = "workoutsDatabase.sqlite"; public WorkoutsDatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); }
任何人都可以看到這可能是爲什麼認爲.jar文件是一個zip?還有,還有什麼我錯過,讓這個工作正常?
以下是錯誤:
Error:: error reading /Users/rdeckert/AndroidStudioProjects/MyPR/app/libs/android-sqlite-asset-helper.jar; cannot read zip file
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/19.0.3/dx --dex --output /Users/rdeckert/AndroidStudioProjects/MyPR/app/build/pre-dexed/debug/android-sqlite-asset-helper-295afb1e2c04cd27e606e7f0ffde55bd32716c79.jar /Users/rdeckert/AndroidStudioProjects/MyPR/app/libs/android-sqlite-asset-helper.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:128)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
我試圖更新Zip文件(數據庫),並沒有做任何事情。
我猜你的壓縮文件的名稱應該是workoutsDatabase.zip而不是workoutsDatabase.sqlite.zip –