netpyoung / SqlCipher4Unity3D

💾 SqlCipher made easy for Unity3d
MIT License
163 stars 37 forks source link

Database ReadOnly on Android #1

Closed poisins closed 5 years ago

poisins commented 7 years ago

Hi! Thanks you for your commitment creating this Unity plugin.

Unfortunately, I have some problems. I can't use DB on Android (haven't tested on iOS yet). Every time I try to Insert data or create tables, I'm receiving ReadOnly exception, even when creating unencrypted database.

Everything is working fine from Unity Editor (Windows). Tried original plugin (Codecoding one, without encryption) with same code and everything is OK.

mobile_failed.txt

netpyoung commented 7 years ago

Can I recive sample project for reproduce that bug?

I think it caused by Android write access permision or problom of path.

poisins commented 7 years ago

Sure.. Weird thing is that Codecoding's plugin is working fine with same configuration and code. Your provided sample code throws ReadOnly error too.

Android OS: 5.0

new_mobileapp_u3d_cipher.zip

netpyoung commented 7 years ago

it is interesting.

my first testing

step
download new_mobileapp_u3d_cipher.zip
delete UnityPackages/SqlCipher4Unity3D/Plugins/x86 for compile error
delete UnityPackages/SqlCipher4Unity3D/Plugins/x64 for compile error
create keystore
android build - with development

Unity 5.6.0b10
Android OS : 6.0 - custom phone 6.0 - api 23

i got follow log that is worked. without readonly error.

LogFilter_20170311_010232.txt


Would you check this?

  1. apk test on your test device. (it is for test device test) qwe123.apk.zip

  2. apk is compiled by follow instruction. so if you don't want to test what i provided try that. (it is for compile enviroment test)

  3. or test .so file base on codecoding/SQLite4Unity3d, change name this repo's libsqlcipher.so to libsqlite3.so .

poisins commented 7 years ago

Ok. Tried all test and got same error - ReadOnly :|

Will try on another device so maybe there's something with my device. Will do some research...

so_test.txt device_test.txt compiler_test.txt

UPDATE: After Googling for for this specific problem on Android devices, it seems that problem is in Android 5.0 OS. SQLCipher for Android has same problems.

netpyoung commented 7 years ago

um.. yea it looks like problem on android 5.0. I try to test on virtual device, but It didn't reproduce that bug.

there is latest android libsqlchiper.so https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/libs/armeabi/libsqlcipher.so

poisins commented 7 years ago

Ok. Replaced existing library with latest SO file, and got this at startup & then crash:

03-13 09:49:30.569 3695-3716 E/art: JNI FindClass called with pending exception 'java.lang.ClassNotFoundException' thrown in unknown throw location 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "net.sqlcipher.database.SQLiteDatabase" on path: DexPathList[[zip file "/data/app/com.poisins.test/base.apk"],nativeLibraryDirectories=[/data/app/com.poisins.test/lib/arm, /vendor/lib, /system/lib]] 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:511) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:469) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at java.lang.String java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:428) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at void java.lang.Runtime.load(java.lang.String, java.lang.ClassLoader) (Runtime.java:329) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at void java.lang.System.load(java.lang.String) (System.java:982) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at boolean com.unity3d.player.UnityPlayer.a(com.unity3d.player.UnityPlayer) ((null):-1) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at boolean com.unity3d.player.UnityPlayer$b$1.handleMessage(android.os.Message) ((null):-1) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:107) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at void android.os.Looper.loop() (Looper.java:194) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] at void com.unity3d.player.UnityPlayer$b.run() ((null):-1) 03-13 09:49:30.570 3695-3716 A/art: art/runtime/thread.cc:1115] 03-13 09:49:30.570 3695-3716 A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3716 (UnityMain)

netpyoung commented 7 years ago

It also need to sqlcipher.jar on https://github.com/sqlcipher/sqlcipher-android-tests/tree/master/libs .

and um... Can i recive device info?

poisins commented 7 years ago

Ok. Will try with JAR file.

My device: http://www.just5.com/latvia/en/blaster-2

Update: Still ReadOnly even with latest library.

netpyoung commented 7 years ago

they are somthing on android-n-preview branch. but i'm not sure they fix that issue. but they try to build x86 only library - https://github.com/sqlcipher/android-database-sqlcipher/commit/c88dfdd2b937f02ee3fa17b5b72eef78b1fa09dc

https://github.com/sqlcipher/sqlcipher-android-tests/pull/17 https://github.com/sqlcipher/android-database-sqlcipher/issues/161

cabanel commented 6 years ago

the problem has not been solved yet?

netpyoung commented 6 years ago

@cabanel yes. at first I havn't that device and make environment reproduce that bug. maybe it fixed future version of sqlcipher/sqlcipher-android. but not tested my version.

SevostianovIvanSIS commented 6 years ago

Hi :). After removal of libs folder from Plugins/Android and using the latest version of arr sqlcipher lib (https://github.com/sqlcipher/sqlcipher-android-tests/tree/master/app/libs) -- everything works fine;

netpyoung commented 6 years ago

@SevostianovIvanSIS thanks report, I will apply that lib later.

netpyoung commented 6 years ago

I applied https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/app/libs/android-database-sqlcipher-3.5.9.aar on this project.

but until stablize, this issue still be opened.