1
Process: com.online.bysmart, PID: 14766
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.online.bysmart-2/base.apk"],nativeLibraryDirectories=[/data/app/com.online.bysmart-2/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libmiio.so"

    at java.lang.Runtime.loadLibrary0(Runtime.java:984)
    at java.lang.System.loadLibrary(System.java:1530)
    at com.xiaomi.miio.JNIBridge.<clinit>(JNIBridge.java:6)
    at com.xiaomi.miio.JNIBridge.hencrypt(Native Method)
    at com.xiaomi.miio.MiioLocalAPI.get_token(MiioLocalAPI.java:779)
    at com.xiaomi.miio.MiioLocalAPI$13.run(MiioLocalAPI.java:761)
    at java.lang.Thread.run(Thread.java:760)

========================================================================= In my app build.gradle file comment:

dependencies {    
    compile fileTree(include:['*.jar'], dir: 'libs')
    compile files('libs/miio.jar')
    ...
}

splits {
    abi {
        enable true
        reset()
        include 'armeabi' ,'armeabi-v7a','arm64-v8a', 'x86'
        universalApk false
    }
}

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

buildTypes {
    release {
        minifyEnabled true
        zipAlignEnabled true
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
}

========================================================================= In root libs directory files:

--libs
    --arm64-v8a//folder name
        --libmiio.so//file
    --miio.jar//file

========================================================================= In proguard-rules.pro:

 -dontwarn com.xiaomi.**
 -keep class com.xiaomi.**{*;}
 -keep interface com.xiaomi.** { *;}
shizhen
  • 12,251
  • 9
  • 52
  • 88
  • it looks not related with proguard, what is your final apk structure? Double check that your apk really includes the needed `.so` for your device architecture. – shizhen Aug 27 '18 at 09:24

2 Answers2

0

I searched on the net these days and finally found the solution! If you are using Android studio, just edit the gradle.properties in the root folder and add android.useDeprecatedNdk=true. Then edit the build.gradle file in your app's folder, set abiFilters as below:

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

}

For more information, you can see How to use 32-bit native libaries on 64-bit Android device, how to use 32bit native libraries on 64 bit Android-L platform on stackoverflow.

You can check this Post as well.

Sardar Khan
  • 845
  • 6
  • 16
0

The root cause is found, because of my app build.gradle configuration:

splits {
    abi {
        enable true
        reset()
        include 'armeabi' ,'armeabi-v7a','arm64-v8a'
        universalApk false
    }
}

But in my libs folder, I don't config armeabi folder

GetSwifty
  • 7,568
  • 1
  • 29
  • 46