Integrating SQLCIPHER in Android Studio Project
Asked Answered
R

1

6

I tried integrating SQLCipher in my Android Application, using this link and also some stack-overflow links(but they are out-dated and differs from official document).

All the steps are correctly followed, and there is no error in the coding part. But at last, when I build the project, the error message I get is :

Error:(11, 0) Gradle DSL method not found: 'defaultConfig()' Possible causes:

  • The project 'android-database-sqlcipher-master1' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • Can anyone please help me to get rid of this error.

    Rightwards answered 17/8, 2015 at 11:7 Comment(0)
    A
    14

    add this to your build.gradle of your app and it should work out of the box:

    dependencies {
         compile 'net.zetetic:android-database-sqlcipher:3.5.2@aar'
         ...
    }
    

    In your code, you should load the 'native libraries' as this 'aar' file contains a few of them.

    SQLiteDatabase.loadLibs(context);
    

    NOTE that you should use the net.sqlcipher.database.SQLiteDatabase instead of android.database.sqlite.SQLiteDatabase, just like a couple of other SQLite classes.

    Adscription answered 16/12, 2015 at 10:23 Comment(9)
    Can you please share the full implementation ?Guanaco
    You can read more info on SQLCipher and Android Studio's integration here.Teeth
    Getting crash on line SQLiteDatabase.loadLibs(context); in samsung device with an error java.lang.UnsatisfiedLinkError:Literality
    How to open encrypted DB file to test DB, Do we have any supported tool. Any suggestion!!Rebekahrebekkah
    @KrunalShah have you got work arount or any fixed for error you getting as mentioned above.Tern
    I got the solution but it was temporary, i clean the project after removing .idea file then run . its works, This crash happened because there is an other third party lib i used that also try to load its so file from libs.Literality
    @Alecio I m facing same Issue in Android StudioBoethius
    @NancyJain after build the project there are some apks are generated in build folder as per the as per the architecture which you are include in build.gradle file, find out the architecture of your device and install that apk in your device which are in build folder.Literality
    Also you will need SqlCipher 3.5.6 for Android N. Previous versions of SqlCipher won't work correctly from Android 7(N) onwards. zetetic.net/blog/2016/6/23/sqlcipher-android-release-n-supportVyky

    © 2022 - 2024 — McMap. All rights reserved.