有没有人遇到过这个错误?
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.swig.simple-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "liborg.swig.simple.example.so"
当我以这种方式加载库时发生错误。
static {
System.loadLibrary("example");
}
我确定当前文件夹中存在“示例”类。
原文由 developergg 发布,翻译遵循 CC BY-SA 4.0 许可协议
请注意,有一个命名约定。您的库需要被称为 libexample.so 。
LoadLibrary(“example”) 将查找 libexample.so。
.so 库需要位于 lib 文件夹下的 apk 中(因为您正在为 Android 开发,所以它需要位于 lib/armeabi 和 lib/armeabi-v7a 文件夹下 - 为什么这两个文件夹?某些版本的 Android 位于 lib 下/armeabi 和一些在 lib/armeabi-v7a 下查看…看看对你有用的东西)。
其他要寻找的东西:
确保为正确的体系结构进行编译(如果为 armeabi v5 进行编译,它将不适用于 armeabiv7 或 armeabiv7s )。
确保您导出的原型在正确的类中使用(检查 hello jni 示例。您的公开函数需要类似于 Java_mypackagename_myjavabridgeclass_myfunction)。
例如,函数 Java_com_example_sample_hello 将在 java 类 com.example.sample 中翻译,函数 hello。