1. 程式人生 > >/lib/arm64, /vendor/lib64, /system/lib64 couldn't find "libstlport_shared.so"

/lib/arm64, /vendor/lib64, /system/lib64 couldn't find "libstlport_shared.so"

當引用so檔案時,部份手機會報這個錯

 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.hx.template-2/base.apk"],nativeLibraryDirectories=[/data/app/com.hx.template-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libstlport_shared.so"

原因是這部份手機是64位處理器的,所以找so的時候先從/lib/arm64, /vendor/lib64, /system/lib64這幾個目錄找。 解決方法: 在gradle.properties加上

android.useDeprecatedNdk=true

build.gradle加上

android {
    ...
    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi"
        }
    }
}

詳情看這裡