我想加载一个.so文件:System.loadLibrary(“ example”); 但是我遇到了这个错误! 这是错误:
致命异常:主要 流程:com.name.ex,PID:30737
java.lang.UnsatisfiedLinkError: dlopen failed: file offset for the library "/data/app/com.name.ex-1/lib/arm/example.so" >= file size: 0 >= 0
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.name.ex.example<clinit>(example.java:582)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newApplication(Instrumentation.java:1020)
at android.app.Instrumentation.newApplication(Instrumentation.java:1005)
at android.app.LoadedApk.makeApplication(LoadedApk.java:670)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6395)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
答案 0 :(得分:0)
您可能将ARM的本机程序集放在错误的目录中……或者文件大小的确为0
。例如,它通常称为armeabi-v7a
而不是arm
(jniLibs
路径可能需要调整,这取决于您的项目外观)
app/src/main/jniLibs/armeabi-v7a
在模块级build.gradle
中,可以定义位置:
android {
...
sourceSets {
main {
jniLibs.srcDir "src/main/jniLibs"
}
}
}