Android Studio的so文件无法加载
黄舟
黄舟 2017-04-17 15:08:06
0
2
856

最近重构之前的项目,调试时出现无法加载so文件。
我so文件放置的路径如下:

出现的错误是:

E/AndroidRuntime: FATAL EXCEPTION: main
  Process: net.comet.example, PID: 6786
  java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/net.comet.example-1/base.apk"],nativeLibraryDirectories=[/data/app/net.comet.example-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libZBarDecoder.so"
      at java.lang.Runtime.loadLibrary(Runtime.java:366)
      at java.lang.System.loadLibrary(System.java:989)
      at com.dtr.zbar.build.ZBarDecoder.<clinit>(ZBarDecoder.java:6)
      at me.ele.hbdteam.widget.ScanView$1.onPreviewFrame(ScanView.java:263)
      at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1565)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:155)
      at android.app.ActivityThread.main(ActivityThread.java:5696)
      at java.lang.reflect.Method.invoke(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

错误里显示的路径中包名后面多了一个 -1 ,不知道怎么回事,我仔细检查了下,发现工程里的包名没有 -1 才对!

我又重新建了一个空的工程,然后把这些文件和部分代码拷贝过去,运行却正常。

百思不得其解,所以上来请教了!

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
刘奇

This problem has been solved because my project integrates Tencent bugly. If I use the method of automatically importing bugly, the code will not find other third-party so files when running; if I use the method of manually importing the bugly jar package , there is no such problem. It should be a bug of bugly!

小葫芦

The extra -1 in the package name in the log is normal. Your exception is in
nativeLibraryDirectories=[/data/app/net.comet.example-1/lib/arm64, /vendor/lib64, / system/lib64]]] couldn't find "libZBarDecoder.so"
The library libZBarDecoder.so was not found.
There are two suggestions
1. Copy libZBarDecoder.so to the armeabi-v7a directory
2. Add jniLibs declaration in app.gradle

android{
    ...
    sourceSets {
        main {
          jniLibs.srcDirs = ['libs']
        }
    }
    ...
}

If it doesn’t work, let’s analyze it in detail

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template