实现sqlcipher-for-android

时间:2014-06-30 09:45:10

标签: android sql sqlcipher

您好我尝试实现sql密码。我从这里使用github的代码(https://github.com/sqlcipher/android-database-sqlcipher)。解压缩源代码并将其导入eclipse。但它没有运行。我得到以下异常。请有人告诉我我做错了什么?

FATAL EXCEPTION: main
 java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared: findLibrary returned null
    at java.lang.Runtime.loadLibrary(Runtime.java:365)
    at java.lang.System.loadLibrary(System.java:535)
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:120)
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:115)
    at example.SQLDemoActivity.onCreate(SQLDemoActivity.java:20)
    at android.app.Activity.performCreate(Activity.java:5020)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
    at android.app.ActivityThread.access$600(ActivityThread.java:149)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:153)
    at android.app.ActivityThread.main(ActivityThread.java:4987)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
    at dalvik.system.NativeStart.main(Native Method)

3 个答案:

答案 0 :(得分:0)

您的项目未正确包含应用程序的原生.so文件。这些是SQLCipher for Android运行所必需的。它们应位于libs文件夹下的特定于平台的文件夹中。作为参考,请查看适用于Android的SQLCipher test suite的项目结构。

答案 1 :(得分:0)

我找到了解决方案: 最初我忘了添加armeabiarmeabi-v7ax86个文件夹。其中包含.so文件。

armeabi

libdatabase_sqlcipher.so
libsqlcipher_android.so
libstlport_shared.so

armeabi-v7a

libdatabase_sqlcipher.so
libsqlcipher_android.so
libstlport_shared.so

x86

libdatabase_sqlcipher.so
libsqlcipher_android.so
libstlport_shared.so

我添加了armeabi,armeabi-v7a,x86。 libs中的文件夹现在可以正常工作。

答案 2 :(得分:0)

您不需要下载.zip包并且不再复制粘贴库。只需add a Gradle dependency,就像compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'一样。 Here您随时可以查看最新版本。