在Android Studio项目中集成SQLCIPHER [英] Integrating SQLCIPHER in Android Studio Project

查看:1517
本文介绍了在Android Studio项目中集成SQLCIPHER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的Android应用程序中集成SQLCipher,使用此链接和一些堆栈 - 溢出链接(但是它们已过时,与官方文档不同)。

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 :

错误:(11,0)Gradle DSL方法找不到:'defaultConfig
可能的原因:

  • 项目android-database-sqlcipher-master1可能使用的Gradle版本不包含方法。
    打开Gradle包装文件
  • 构建文件可能缺少Gradle插件。
    应用Gradle插件
  • 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.

    推荐答案

    将此添加到您的应用程序的build.gradle中,它应该可以开箱即用:

    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'
         ...
    }
    

    在您的代码中,您应该加载'本地库',因为'aar'文件包含其中的一些。

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

    SQLiteDatabase.loadLibs(context);
    

    注意,您应该使用 net.sqlcipher.database.SQLiteDatabase 而不是 android.database.sqlite.SQLiteDatabase ,就像一对其他SQLite类。

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

    这篇关于在Android Studio项目中集成SQLCIPHER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆