java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader

前端 未结 17 1783
耶瑟儿~
耶瑟儿~ 2020-11-29 22:21

Is there someone who had experience with this error?

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file \"/data/app/org.swig         


        
相关标签:
17条回答
  • 2020-11-29 22:31

    This helped me. Sharing it for someone who might come up with same issue.

    android {
        ....
        defaultConfig {
            ....
            ndk {
                abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-29 22:33

    -if gradle.properties not available then first add that file and add android.useDeprecatedNdk=true

    -use this code in build.gradle

    defaultConfig {
        applicationId 'com.example.application'
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 11
        versionName "1.1"
        ndk {
            abiFilters "armeabi"
        }
    }
    

    `

    0 讨论(0)
  • 2020-11-29 22:36

    Some old gradle tools cannot copy .so files into build folder by somehow, manually copying these files into build folder as below can solve the problem:

    build/intermediates/rs/{build config}/{support architecture}/
    

    build config: beta/production/sit/uat

    support architecture: armeabi/armeabi-v7a/mips/x86

    0 讨论(0)
  • 2020-11-29 22:37

    Yet another crash cause and possible solution is described in this article: https://medium.com/keepsafe-engineering/the-perils-of-loading-native-libraries-on-android-befa49dce2db

    Briefly:
    in build.gradle

    dependencies {
        implementation 'com.getkeepsafe.relinker:relinker:1.2.3'
    }
    

    in code

    static {
        try {
            System.loadLibrary("<your_libs_name>");
        } catch (UnsatisfiedLinkError e) {
            ReLinker.loadLibrary(context, "<your_libs_name>");
        }
    }
    
    0 讨论(0)
  • 2020-11-29 22:38

    In my case After running the ndk-build in the jni folder the shared library was created under the libs folder but the path specified in build.gradle

    sourceSets.main {
            jni.srcDirs = []
            jniLibs.srcDir 'src/main/jniLibs'
        }
    

    so I need to move the created shared library to jnilibs folder and it worked!

    0 讨论(0)
  • 2020-11-29 22:40

    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"
        }
    }
    }
    
    0 讨论(0)
提交回复
热议问题