向Android项目添加.so文件
我正在尝试将SQLCipher添加到我的项目中。我能够将jar文件链接到项目,但是链接提供的.so文件时出现问题 因此,当我试图打开数据库时,我得到了不满意的链接错误向Android项目添加.so文件,android,sqlcipher,Android,Sqlcipher,我正在尝试将SQLCipher添加到我的项目中。我能够将jar文件链接到项目,但是链接提供的.so文件时出现问题 因此,当我试图打开数据库时,我得到了不满意的链接错误 任何人都可以告诉我向项目中添加.so文件并使其运行的最佳方法。除了jar文件之外,您还需要包含.so文件。在我的项目中,我有: jar files in project_root/libs/ .so files in project_root/libs/armeabi/ 还要确保正确添加了.jar文件。转到Project Pro
任何人都可以告诉我向项目中添加.so文件并使其运行的最佳方法。除了jar文件之外,您还需要包含.so文件。在我的项目中,我有:
jar files in project_root/libs/
.so files in project_root/libs/armeabi/
还要确保正确添加了.jar文件。转到Project Properties->Java构建路径->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”):
您是否可以使用adb shell命令验证解包后将哪些文件部署到模拟器中。我以前见过一个问题,.so文件没有打包到.apk文件中,这是因为IDE没有指向应用程序的正确本机库路径。您没有将.so文件添加到项目中。您只需将它们放在名为
armeabi
的文件夹中,该文件夹与jar文件位于同一文件夹中。这些jar文件将在您从代码中调用SQLiteDatabase.loadLibs
时自动加载这些.so文件。多次执行相同的操作,但我仍然获得java.lang.unsatifiedlinkerror:dbopen在调用getWritableDatabase
之前,请确保调用SQLiteDatabase.loadLibs()
。有关详细信息,请参见我的编辑。