java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader [英] java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader
问题描述
有人遇到过这个错误吗?
Is there someone who had experience with this error?
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"
通过这种方式加载库时发生错误.
Error occurs when I load library by this way.
static {
System.loadLibrary("example");
}
我确定当前文件夹中存在示例"类.
I'm sure 'example' class is exist in the current folder.
推荐答案
请注意,有一个命名约定.你的库需要被称为 libexample.so .
Please note that there's a naming convention. Your lib needs to be called libexample.so .
LoadLibrary("example") 将查找 libexample.so.
LoadLibrary("example") will look for libexample.so.
.so 库需要在 lib 文件夹下的 apk 中(因为您是为 Android 开发,所以它需要在 lib/armeabi 和 lib/armeabi-v7a 文件夹下 - 为什么这两个文件夹?某些版本的 Android在 lib/armeabi 下查看,在 lib/armeabi-v7a 下查看一些......看看什么对你有用).
The .so library needs to be inside the apk under the lib folder (since you are developing for Android, it needs to be under the lib/armeabi and lib/armeabi-v7a folders - why both folders ? some versions of Android look under lib/armeabi and some look under lib/armeabi-v7a ... se what works for you ).
其他需要寻找的东西:
确保您针对正确的架构进行编译(如果您为 armeabi v5 编译,它将无法在 armeabiv7 或 armeabiv7s 上运行).
make sure you compile for the correct architecture (if you compile for armeabi v5 it won't work on armeabiv7 or armeabiv7s ).
确保您导出的原型在正确的类中使用(检查 hello jni 示例.您公开的函数需要类似于 Java_mypackagename_myjavabridgeclass_myfunction).
make sure your exported prototypes are used in the correct class (check the hello jni example. Your exposed functions need to look something like Java_mypackagename_myjavabridgeclass_myfunction).
例如函数 Java_com_example_sample_hello 将在 java 类 com.example.sample 中转换,函数 hello.
For example the function Java_com_example_sample_hello will translate in the java class com.example.sample , function hello.
这篇关于java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!