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

Updation from android-database-sqlcipher to sqlcipher-android #643

Open
ashishgingercube opened this issue Mar 21, 2024 · 23 comments
Open

Comments

@ashishgingercube
Copy link

Hi, my application has been using android-database-sqlcipher for quite some years now. Today I got the following message from playstore.

net.zetetic:android-database-sqlcipher has reported android-database-sqlcipher:3.5.9 as outdated. You may not be able to release future versions of your app with this SDK version to production or open testing.

so I replaced implementation ‘net.zetetic:android-database-sqlcipher:3.5.9@aar’ with implementation ‘net.zetetic:sqlcipher-android:4.5.5@aar’

But on doing that I am getting this issue.

Task :maxRVU:mergeMaxrvuDebugNativeLibs FAILED
Execution failed for task ‘:maxRVU:mergeMaxrvuDebugNativeLibs’.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
2 files found with path ‘lib/arm64-v8a/libsqlcipher.so’ from inputs:

  • /Users/ashish/.gradle/caches/transforms-3/47cad2ebd25762db6d4f72d65143456b/transformed/jetified-sqlcipher-android-4.5.5/jni/arm64-v8a/libsqlcipher.so
  • /Users/ashish/.gradle/caches/transforms-3/ff8ddd5b58a3b5727c6ff94414d581dd/transformed/jetified-android-database-sqlcipher-3.5.9/jni/arm64-v8a/libsqlcipher.so

Can you help me with what I can do to fix this issues?

Thank you.

@developernotes
Copy link
Member

Hi @ashishgingercube,

You have to remove the android-database-sqlcipher reference from Gradle. We have migration instruction here 1.

Footnotes

  1. https://www.zetetic.net/sqlcipher/sqlcipher-for-android-migration/

@ashishgingercube
Copy link
Author

ashishgingercube commented Mar 21, 2024

Hi, I have removed
implementation 'net.zetetic:android-database-sqlcipher:3.5.9@aar'

and added

implementation 'net.zetetic:sqlcipher-android:4.5.5@aar'
implementation 'androidx.sqlite:sqlite:2.2.0'

packagingOptions {
exclude 'lib/arm64-v8a/libsqlcipher.so'
exclude 'lib/armeabi-v7a/libsqlcipher.so'
exclude 'lib/x86/libsqlcipher.so'
exclude 'lib/x86_64/libsqlcipher.so'
}

and in my activity I have changed this

SQLiteDatabase.loadLibs(_mContext);

to

SQLiteDatabase.loadLibs(_mContext, libraries -> {
for (String library : libraries) {
ReLinker.loadLibrary(_mContext, library);
}
});

But now I am getting this issue

java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlcipher.so" not found

Can you please help me with this issue?

Thank you.

@developernotes
Copy link
Member

Why are you excluding the native libsqlcipher.so? The native library is included within the SQLCipher for Android AAR and is needed.

@DinShopper
Copy link

Hello fellows, I received the same mesage from the playstore. "net.zetetic:android-database-sqlcipher has reported android-database-sqlcipher:3.5.9 as outdated. You may not be able to release future versions of your app with this SDK version to production or open testing." does that mean i have to update it to version starting with 4.x or migrate to the newer "net.zetetic:sqlcipher-android" library. I know the latter would be better option, but it caught me off guard and full migration to different API would take time and testing. So can i just update it to version 4.x and migrate just the db's?

@ashishgingercube
Copy link
Author

ashishgingercube commented Mar 21, 2024

Task :maxRVU:mergeMaxrvuDebugNativeLibs FAILED Execution failed for task ‘:maxRVU:mergeMaxrvuDebugNativeLibs’. A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction 2 files found with path ‘lib/arm64-v8a/libsqlcipher.so’ from inputs:

  • /Users/ashish/.gradle/caches/transforms-3/47cad2ebd25762db6d4f72d65143456b/transformed/jetified-sqlcipher-android-4.5.5/jni/arm64-v8a/libsqlcipher.so
  • /Users/ashish/.gradle/caches/transforms-3/ff8ddd5b58a3b5727c6ff94414d581dd/transformed/jetified-android-database-sqlcipher-3.5.9/jni/arm64-v8a/libsqlcipher.so

I excluded the libsqlcipher.so because I was getting this error

Task :maxRVU:mergeMaxrvuDebugNativeLibs FAILED
Execution failed for task ‘:maxRVU:mergeMaxrvuDebugNativeLibs’.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
2 files found with path ‘lib/arm64-v8a/libsqlcipher.so’ from inputs:

/Users/ashish/.gradle/caches/transforms-3/47cad2ebd25762db6d4f72d65143456b/transformed/jetified-sqlcipher-android-4.5.5/jni/arm64-v8a/libsqlcipher.so
/Users/ashish/.gradle/caches/transforms-3/ff8ddd5b58a3b5727c6ff94414d581dd/transformed/jetified-android-database-sqlcipher-3.5.9/jni/arm64-v8a/libsqlcipher.so

Can you help me with this issue? And how long will it be until I can no longer use the current version I am using?

Thank you.

@developernotes
Copy link
Member

Hello @DinShopper,

The android-database-sqlcipher library was officially deprecated last year 1. You are welcome to migrate to the 4.x series of that library, however, please note that Community updates are no longer being made. The long-term replacement library is sqlcipher-android 2 and is kept up-to-date with public SQLCipher core releases. We have a migration guide available here 3. If you have a Commercial need for android-database-sqlcipher, please reach out 4.

Footnotes

  1. https://www.zetetic.net/blog/2023/08/31/sqlcipher-4.5.5-release/

  2. https://github.com/sqlcipher/sqlcipher-android/

  3. https://www.zetetic.net/sqlcipher/sqlcipher-for-android-migration/

  4. support@zetetic.net

@DinShopper
Copy link

Hello @developernotes,

Thank you very much for the fast response. I am planning to update to the sqlcipher-android, but for the time being a way to avoid the Google Play Store message is a priority for me. Is there a page (link) where i can see which versions of the old library (android-database-sqlcipher) are currently outdated for the Google Play Store. Are only the 3.x versions marked as outdated, or are the 4.x versions also considered outdated?

@developernotes
Copy link
Member

@DinShopper,

android-database-sqlcipher 4.2.0 and up to 4.5.4 (the last Community edition release of android-database-sqlcipher) are not marked as outdated currently. If you are migrating from version 3.x to 4.x of SQLCipher (regardless of the library itself), please also review the Upgrading to SQLCipher 4 guidance here 1.

Footnotes

  1. https://discuss.zetetic.net/t/upgrading-to-sqlcipher-4/3283

@developernotes
Copy link
Member

Hi @ashishgingercube,

Please try cleaning your Gradle cache if you are still getting a merge native libs error if you've already settled on either only android-database-sqlcipher or sqlcipher-android within your application. Also, please remove the exclude lines within your packagingOptions.

@asifsaifi92
Copy link

Hi @developernotes ,

I am getting this error and app is getting crashed.

java.lang.UnsatisfiedLinkError: No implementation found for void net.sqlcipher.database.SQLiteDatabase.dbopen(java.lang.String, int) (tried Java_net_sqlcipher_database_SQLiteDatabase_dbopen and Java_net_sqlcipher_database_SQLiteDatabase_dbopen__Ljava_lang_String_2I)

@developernotes
Copy link
Member

developernotes commented Mar 22, 2024

Hi @asifsaifi92,

I am getting this error and app is getting crashed.
java.lang.UnsatisfiedLinkError: No implementation found for void net.sqlcipher.database.SQLiteDatabase.dbopen(java.lang.String, int) (tried Java_net_sqlcipher_database_SQLiteDatabase_dbopen and Java_net_sqlcipher_database_SQLiteDatabase_dbopen__Ljava_lang_String_2I)

Unfortunately, this is not enough information to diagnose the issue you are experiencing. Below are some questions that would help us better understand your situation:

  • What SQLCipher for Android library are you using (i.e., android-database-sqlcipher or sqlcipher-android)?
  • What version of SQLCipher for Android are you using?
  • Are you upgrading from a previous version of SQLCipher for Android?
    • If so, what version?
    • Does the error go away if you revert back to the previous version?
  • Are you excluding the native libraries (similar to what @ashishgingercube did above)?
  • Are you using ProGuard?
    • If so, does disabling ProGuard resolve the issue?
  • Are you loading the native SQLCipher library prior to utilizing any of the SQLCipher for Android Java classes?
  • What have you done to troubleshoot the issue thus far?

If your issue is not related to the initial posting, please consider posting a new separate issue.

@ashishgingercube
Copy link
Author

Hi @ashishgingercube,

Please try cleaning your Gradle cache if you are still getting a merge native libs error if you've already settled on either only android-database-sqlcipher or sqlcipher-android within your application. Also, please remove the exclude lines within your packagingOptions.

Hi, thanks for the reply. So I went back & deleted the cache folder in my .gradle folder. Invalidated the cache in my android studio. Also removed the exclude lines as you instructed. Then in my gradle file I replaced 'implementation 'net.zetetic:android-database-sqlcipher:3.5.9@aar'' with 'implementation 'net.zetetic:sqlcipher-android:4.5.5@aar''. But still I'm getting this error -

2 files found with path 'lib/arm64-v8a/libsqlcipher.so' from inputs:

  • /Users/ashish/.gradle/caches/transforms-3/47cad2ebd25762db6d4f72d65143456b/transformed/jetified-sqlcipher-android-4.5.5/jni/arm64-v8a/libsqlcipher.so
  • /Users/ashish/.gradle/caches/transforms-3/ff8ddd5b58a3b5727c6ff94414d581dd/transformed/jetified-android-database-sqlcipher-3.5.9/jni/arm64-v8a/libsqlcipher.so

Can you please help me with a solution of my problem? Thanks in advance.

@developernotes
Copy link
Member

Hi @ashishgingercube,

You will need to review your dependencies, both direct and transitive as it appears you are pulling in both android-database-sqlcipher and sqlcipher-android, both of which bundle native libraries.

@ashishgingercube
Copy link
Author

Hi @ashishgingercube,

You will need to review your dependencies, both direct and transitive as it appears you are pulling in both android-database-sqlcipher and sqlcipher-android, both of which bundle native libraries.

Hi, thanks for the reply. I checked my dependencies & found that this dependency creates android-database-sqlcipher folder

implementation "com.commonsware.cwac:saferoom.x:0.5.1"

But I can't remove this because it is connected to a lot of places in my application. Can you suggest a way out for me? Thank you.

@ashishgingercube
Copy link
Author

Hi @ashishgingercube,

You will need to review your dependencies, both direct and transitive as it appears you are pulling in both android-database-sqlcipher and sqlcipher-android, both of which bundle native libraries.

Hi, also can you let me know an approximate time till when I can use android-database-sqlcipher version 4.2.0+ ? Since removing com.commonsware.cwac:saferoom.x:0.5.1 on short notice will require a lot of work because my app has live users. Thanks in advance.

@developernotes
Copy link
Member

Hello @ashishgingercube - we can't provide an exact time for how long you can use 4.2.0. As mentioned earlier, the android-database-sqlcipher package is deprecated. You are free to keep using it in your application, though you will not see any updates for it in the future. At some point we may choose to de-list it, but that will probably not be in the immediate future. For now it is safe to use it to get your application updated and released, but you should consider it a priority to move to sqlcipher-android in a timely manner.

@ashishgingercube
Copy link
Author

Hello @ashishgingercube - we can't provide an exact time for how long you can use 4.2.0. As mentioned earlier, the android-database-sqlcipher package is deprecated. You are free to keep using it in your application, though you will not see any updates for it in the future. At some point we may choose to de-list it, but that will probably not be in the immediate future. For now it is safe to use it to get your application updated and released, but you should consider it a priority to move to sqlcipher-android in a timely manner.

Hi, thanks for the update. Much appreciated.

@DinShopper
Copy link

Hello, @developernotes

I have a question: Is there a specific rationale for validating the result of executing 'PRAGMA cipher_migrate;' to be (0), or can I rely on the library itself to throw exceptions afterwards to detect that migration failed?

@developernotes
Copy link
Member

Hi @DinShopper,

No, you should not expect an exception to be raised when executing PRAGMA cipher_migrate; you should check the numeric result code for success.

@ashishgingercube
Copy link
Author

ashishgingercube commented Apr 26, 2024

Hi @DinShopper, so when I upgraded to "net.zetetic:android-database-sqlcipher:4.2.0@aar" & "com.commonsware.cwac:saferoom.x:1.0.0" & ran the application I got this error "Caused by: net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;". But when I uninstall the application & re-run it again then it works. This is my code.

mInstance = Room.databaseBuilder(context,
MaxRVURewampDatabase.class, "MaxRVU-db.sql")
.openHelperFactory(factory)
.allowMainThreadQueries()
.addMigrations(MIGRATION_1_2)
.build();

Can you help me in identifying what could be the issue here? Thanks in advance.

@DinShopper
Copy link

Hi, @developernotes

I see, i though that i can rely on the exception that is thrown afterwards, because after the hook tries to migrate the database - if it's ok the opened connection can be used and if the hook fails it throws an exception that like this "net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;"

@DinShopper
Copy link

Hi, @ashishgingercube

After you uninstall the application and install it again the database is newly created with the SQLCipher 4 settings and that's why it's ok and working. I suspect in your case that you are not migrating the already created databases from the previous version of your application.

@developernotes
Copy link
Member

Hi @DinShopper,

I see, i though that i can rely on the exception that is thrown afterwards, because after the hook tries to migrate the database - if it's ok the opened connection can be used and if the hook fails it throws an exception that like this "net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;"

Yes, that is fine.

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

4 participants