1. 程式人生 > >sqlcipher 加密資料庫問題3

sqlcipher 加密資料庫問題3

1、加密資料庫sqlcipher 2.1 (大約),執行在android4.4 報錯

(1)

09-04 05:15:59.627: E/dalvikvm(1444): dlopen("/data/app-lib/com.glenet.hm-1/libdatabase_sqlcipher.so") failed: dlopen failed: library "/system/lib/libhoudini.so" not found
09-04 05:15:59.647: E/AndroidRuntime(1444): FATAL EXCEPTION: main
09-04 05:15:59.647: E/AndroidRuntime(1444): Process: com.glenet.hm, PID: 1444
09-04 05:15:59.647: E/AndroidRuntime(1444): java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libhoudini.so" not found
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at java.lang.Runtime.loadLibrary(Runtime.java:364)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at java.lang.System.loadLibrary(System.java:526)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:143)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:136)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:80)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.app.ActivityThread.access$1500(ActivityThread.java:135)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.os.Handler.dispatchMessage(Handler.java:102)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.os.Looper.loop(Looper.java:136)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at java.lang.reflect.Method.invoke(Method.java:515)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-04 05:15:59.647: E/AndroidRuntime(1444): 	at dalvik.system.NativeStart.main(Native Method)

(2)紅米1s 等

09-09 13:34:02.665: E/dalvikvm(7536): dlopen("/data/app-lib/com.glenet.hm-1/libdatabase_sqlcipher.so") failed: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
09-09 13:34:02.668: E/AndroidRuntime(7536): FATAL EXCEPTION: main
09-09 13:34:02.668: E/AndroidRuntime(7536): Process: com.glenet.hm, PID: 7536
09-09 13:34:02.668: E/AndroidRuntime(7536): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at java.lang.Runtime.loadLibrary(Runtime.java:371)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at java.lang.System.loadLibrary(System.java:531)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:143)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:136)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at com.lbe.security.service.core.client.b.x.callApplicationOnCreate(Unknown Source)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4564)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.app.ActivityThread.access$1500(ActivityThread.java:151)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.os.Handler.dispatchMessage(Handler.java:110)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.os.Looper.loop(Looper.java:193)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at android.app.ActivityThread.main(ActivityThread.java:5315)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at java.lang.reflect.Method.invoke(Method.java:515)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:660)
09-09 13:34:02.668: E/AndroidRuntime(7536): 	at dalvik.system.NativeStart.main(Native Method)



解決:

升級資料庫, 2.2.2及以上版本

建議升級到2.2.2 ,因為3.1 與2.x 不是完美相容,

若從2.x升級到到3.x 讀取資料庫會報錯哦,見下方

2、程式使用sqlcipher2.2 升級到 3.1 ,程式安裝後 開啟會報錯

同樣,從3.1降級到2.2 也會報錯

09-04 12:24:25.010: E/lights(2773): write_int: path /sys/devices/virtual/misc/melfas_touchkey/brightness, value 1
09-04 12:24:26.020: E/Database(3612): CREATE TABLE android_metadata failed
09-04 12:24:26.020: E/Database(3612): Failed to setLocale() when constructing, closing the database
09-04 12:24:26.020: E/Database(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:907)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)
09-04 12:24:26.020: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:26.020: E/Database(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:26.020: E/Database(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:26.020: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:144)
09-04 12:24:26.020: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:26.020: E/Database(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:26.020: E/Database(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:26.020: E/Database(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:26.020: E/Database(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:26.020: E/Database(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:26.020: E/Database(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:26.020: E/Database(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:26.020: E/Database(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:26.020: E/Database(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:26.020: E/Database(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:26.020: E/Database(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:26.020: E/Database(3612): 	at dalvik.system.NativeStart.main(Native Method)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): Couldn't open hm.db for writing (will try read-only):
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:907)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:144)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:26.025: E/SQLiteOpenHelper(3612): 	at dalvik.system.NativeStart.main(Native Method)
09-04 12:24:26.550: E/lights(2773): write_int: path /sys/devices/virtual/misc/melfas_touchkey/brightness, value 2
09-04 12:24:26.600: E/Database(3612): CREATE TABLE android_metadata failed
09-04 12:24:26.610: E/Database(3612): Failed to setLocale() when constructing, closing the database
09-04 12:24:26.610: E/Database(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:934)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:219)
09-04 12:24:26.610: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:26.610: E/Database(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:26.610: E/Database(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:26.610: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:144)
09-04 12:24:26.610: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:26.610: E/Database(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:26.610: E/Database(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:26.610: E/Database(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:26.610: E/Database(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:26.610: E/Database(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:26.610: E/Database(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:26.610: E/Database(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:26.610: E/Database(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:26.610: E/Database(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:26.610: E/Database(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:26.610: E/Database(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:26.610: E/Database(3612): 	at dalvik.system.NativeStart.main(Native Method)
09-04 12:24:27.190: E/Database(3612): CREATE TABLE android_metadata failed
09-04 12:24:27.190: E/Database(3612): Failed to setLocale() when constructing, closing the database
09-04 12:24:27.190: E/Database(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:907)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)
09-04 12:24:27.190: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:27.190: E/Database(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:27.190: E/Database(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:27.190: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:146)
09-04 12:24:27.190: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:27.190: E/Database(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:27.190: E/Database(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:27.190: E/Database(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:27.190: E/Database(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:27.190: E/Database(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:27.190: E/Database(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:27.190: E/Database(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:27.190: E/Database(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:27.190: E/Database(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:27.190: E/Database(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:27.190: E/Database(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:27.190: E/Database(3612): 	at dalvik.system.NativeStart.main(Native Method)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): Couldn't open hm.db for writing (will try read-only):
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:907)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:197)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:146)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:27.195: E/SQLiteOpenHelper(3612): 	at dalvik.system.NativeStart.main(Native Method)
09-04 12:24:27.740: E/Database(3612): CREATE TABLE android_metadata failed
09-04 12:24:27.740: E/Database(3612): Failed to setLocale() when constructing, closing the database
09-04 12:24:27.740: E/Database(3612): net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:934)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:219)
09-04 12:24:27.740: E/Database(3612): 	at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:184)
09-04 12:24:27.740: E/Database(3612): 	at com.glenet.hm.sqlite.HmAppDbHelper.getReadableDatabase(HmAppDbHelper.java:77)
09-04 12:24:27.740: E/Database(3612): 	at com.glenet.hm.sqlite.DbTableIsExist.tabbleIsExist(DbTableIsExist.java:22)
09-04 12:24:27.740: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.initTable(HmApplication.java:146)
09-04 12:24:27.740: E/Database(3612): 	at com.glenet.hm.sys.HmApplication.onCreate(HmApplication.java:83)
09-04 12:24:27.740: E/Database(3612): 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:972)
09-04 12:24:27.740: E/Database(3612): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3280)
09-04 12:24:27.740: E/Database(3612): 	at android.app.ActivityThread.access$2200(ActivityThread.java:117)
09-04 12:24:27.740: E/Database(3612): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
09-04 12:24:27.740: E/Database(3612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 12:24:27.740: E/Database(3612): 	at android.os.Looper.loop(Looper.java:130)
09-04 12:24:27.740: E/Database(3612): 	at android.app.ActivityThread.main(ActivityThread.java:3691)
09-04 12:24:27.740: E/Database(3612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-04 12:24:27.740: E/Database(3612): 	at java.lang.reflect.Method.invoke(Method.java:507)
09-04 12:24:27.740: E/Database(3612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
09-04 12:24:27.740: E/Database(3612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
09-04 12:24:27.740: E/Database(3612): 	at dalvik.system.NativeStart.main(Native Method)


解決(未完善):

The same thing has happened to me and it is because after the update of the SQLCipher library i also needed to upgrade the database from the version 1.1.x i was using to 2.2.2. See here why. To do that you need to use the SQLiteDatabase.upgradeDatabaseFormatFromVersion1To2(File dbPath, String key). The problem is that this method does not preserve the db version so we need to do that manually. So the code will be like this:

//Open the old formatted db with cipher_use_hmac = OFF;SQLiteDatabaseHook hook =newSQLiteDatabaseHook(){publicvoid preKey(SQLiteDatabase database){}publicvoid postKey(SQLiteDatabase database){
         database.rawExecSQL("PRAGMA cipher_use_hmac = OFF;");}};//Read the db versionSQLiteDatabase old_db =SQLiteDatabase.openOrCreateDatabase(path, mPassword, mFactory, hook);int version = old_db.getVersion();
 old_db.close();//Do the upgrade to 2.x formattry{SQLiteDatabase.upgradeDatabaseFormatFromVersion1To2(newFile(path), mPassword);}catch(Exception e){
     e.printStackTrace();}//Manually set the db version to the updated db.SQLiteDatabase updated_db =SQLiteDatabase.openOrCreateDatabase(path, mPassword, mFactory);
updated_db.setVersion(version);

The above code will permanently update the SQLCipher database format to 2.2.2 version. If you want to update to the new 3.x format, the process is different and you need to use the PRAGMA cipher_migrate method (See here). I avoided the 3.x format because the default KDF iteration count is 64000 (up from 4000) which was making the readings/writings to the database quite slow. The 2.2.2 version is compatible with KitKat.

3、附下載地址

2.2.2 包含so庫

https://s3.amazonaws.com/sqlcipher/SQLCipher+for+Android+v2.2.2.zip 

2.2.2 原始碼,不含二進位制檔案

https://github.com/sqlcipher/android-database-sqlcipher/archive/v2.2.2.zip

3.1包含so庫

https://s3.amazonaws.com/sqlcipher/SQLCipher+for+Android+v3.1.0.zip

3.1 原始碼,不含二進位制檔案

https://github.com/sqlcipher/android-database-sqlcipher/archive/v3.1.0.zip

所有版本-原始碼,不含二進位制檔案