Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating SQLCIPHER in Android Studio Project

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.

    like image 821
    Gautham Raj Ayyapparaj Avatar asked Aug 17 '15 11:08

    Gautham Raj Ayyapparaj


    1 Answers

    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.

    like image 100
    Alécio Carvalho Avatar answered Nov 15 '22 04:11

    Alécio Carvalho