3

我正在尝试将 SQLCipher 添加到我的项目中。我能够将 jar 文件链接到项目,但链接提供的 .so 文件时出现问题。

因此,当我尝试打开数据库时,我得到了 UnSatisfiedLinkError。

谁能告诉我将 .so 文件添加到项目并使其运行的最佳方法。

4

2 回答 2

4

除了 jar 文件,您还需要包含 .so 文件。在我的项目中,我有:

jar files in project_root/libs/
.so files in project_root/libs/armeabi/

还要确保您已正确添加 .jar 文件。转到Project Properties -> Java Build Path -> Libraries选项卡确保commonc-codec.jar, gueva-r09.jar,sqlcipher.jar被添加在那里。

编辑

1) Add a single sqlcipher.jar and a few .so’s to the application libs directory
2) Update the import path from android.database.sqlite.* to info.guardianproject.database.sqlite.* in any source files that reference it. The original android.database.Cursor can still be used unchanged.
3) Init the database in onCreate() and pass a variable argument to the open database method with a password*:

    SQLiteDatabase.loadLibs(this); //first init the db libraries with the context
    SQLiteOpenHelper.getWritableDatabase(“thisismysecret”):
于 2011-11-18T10:39:43.290 回答
0

您可以使用 adb shell 命令来验证解压缩后将哪些文件部署到您的模拟器。我之前看到过 .so 文件没有打包在 .apk 文件中的问题,这是由于 IDE 没有为您的应用程序指向正确的本机库路径。

于 2011-11-18T17:19:34.873 回答