在 Android Studio 中添加 .so 文件

问题描述:

我正在尝试添加一个外部库 Scandit.我不断收到此错误:

I am trying to add an external library, Scandit. I keep getting this error:

    java.lang.UnsatisfiedLinkError: Couldn't load scanditsdk-android-3.3.1 from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.clover.barcode2-1.apk,libraryPath=/data/app-lib/com.clover.barcode2-1]: findLibrary returned null
    at java.lang.Runtime.loadLibrary(Runtime.java:365)
   .....

我认为这是因为我没有正确包含库附带的 .so 文件,但我不知道如何去做.

I assume it is because I am not properly including the .so file that comes with the library, but I can't figure out how to do it.

我正在使用 Android Studio,我通过转到模块设置 -> 库添加了库,并添加了包含 jar 的目录和包含 so 文件的目录.

I am using Android Studio and I added the library by going to module settings -> libraries and added the directory with the jar and the directory with the so file.

您可以使用 gradle 0.7.2+ 在 Android Studio 中添加预构建的 *.so 文件.首先在/app/src/main/这个位置创建jniLibs,复制jniLibs中所有带有*.so文件的文件夹(armeabi、armeabi-v7a、mips、x86).

You can add pre built *.so files in Android Studio using gradle 0.7.2+. First create the jniLibs at this location /app/src/main/ location and copy the all the folder with *.so files (armeabi, armeabi-v7a, mips, x86) in the jniLibs.