Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net.sqlcipher.database.SQLiteMisuseException with Multidex Build #324

Closed
llmagicll opened this issue Mar 28, 2017 · 3 comments
Closed

net.sqlcipher.database.SQLiteMisuseException with Multidex Build #324

llmagicll opened this issue Mar 28, 2017 · 3 comments

Comments

@llmagicll
Copy link

llmagicll commented Mar 28, 2017

Hi, We recently faced an issue of net.sqlcipher.database.SQLiteMisuseException: error code 21: not an error on many devices with Android 7.0 and 7.1 reported by GooglePlay. As i know, it's a multithread related issue. However the strange part is that it occurs only if we build our apk with Multidex enabled. Without multidex build, everything is fine. But i cannot produce it on my own device and simulators, it works fine on my own devices. (We are using v3.1.0, cause there are other issues that using the latest version). Did anyone face the same issue with multidex? Thanks for help.

The full stack is as following:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fourdesire.spacewalk/com.MYACTIVITY}: net.sqlcipher.database.SQLiteMisuseException: error code 21: not an error at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) Caused by: net.sqlcipher.database.SQLiteMisuseException: error code 21: not an error at net.sqlcipher.database.SQLiteStatement.native_1x1_long(Native Method) at net.sqlcipher.database.SQLiteStatement.simpleQueryForLong(SQLiteStatement.java:128) at net.sqlcipher.database.SQLiteDatabase.getVersion(SQLiteDatabase.java:1272) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:166) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129) at MY_CLASSS.getDatabase(StepEnctyptDatabase.java:113) at MY_CLASSS.getDbStatusItem(StepEnctyptDatabase.java:199) at MY_CLASSS.checkNeedMigration(StepEnctyptDatabase.java:173) at MY_CLASSS.<init>(StepEnctyptDatabase.java:65) at MY_CLASSS.getSharedDatabase(StepEnctyptDatabase.java:81) at MY_ACTIVITY.onCreate(SWUnityExternalJavaPlugin.java:134) at android.app.Activity.performCreate(Activity.java:6672) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612) ... 9 more

@developernotes
Copy link
Member

Hello @llmagicll

We are using v3.1.0

You are using SQLCipher for Android v3.1.0 on Android 7 and 7.1? We didn't add support for Android 7 until 3.5.0, and the current version of the library is 3.5.6. Can you try upgrading to the latest version of the library?

As i know, it's a multithread related issue.

Are you utilizing coordinated access to resources such as the connection object within your application since you are utilizing multiple threads?

@llmagicll
Copy link
Author

Hi @developernotes
We used v3.1.0 for Android 7 and 7.1 for a long time, and it actually works fine without multidex enabled. But recently we need to integrate more SDK so let multidex enabled, and got lots's of SQLiteMisuseException from users (about 30% of users with android 7).

Are you utilizing coordinated access to resources such as the connection object within your application since you are utilizing multiple threads?

We have a service and an activity that can both access the database, and we used synchronized carefully to envelope every method that related to database (e.g. query, delete...). However we didn't have this exception before until the apk built with multidex

We will upgrade to the 3.5.6, however since i can't reproduce this issue, we cannot confirm if it will be alright on the live store (we already rollback to the Apk that without multidex on GoogleStore).

Plz let me know if any further information that i can provide to you to help address the issue. Thank you very much!

@developernotes
Copy link
Member

Hello @llmagicll

I am going to close this ticket as you have moved the discussion of the issue over to our Discuss site. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants