Search code examples
androidandroid-studioshared-librariesandroid-6.0-marshmallowaac

Android M API 23 error to load lib .so files


hello guys i have aac decoder in my app

it was working great when i was on API level 22 ..

but when i was using API level 23 .. my app goes crash and gives me an error unable to lib files

java.lang.UnsatisfiedLinkError: dlopen failed:

i was search lots of pages but nothing helping found .. problem was only on latest version of android .. app was working great in older version of android ..

here is my libs

aacdecoder-android-libs-0.8.zip

|---src |---main |---jniLibs

              > aacdecoder-android-0.8.jar
                > armeabi
                   > libaacdecoder.so
              > armeabi-v7a
                   > libaacdecoder.so
              > mips
                  > libaacdecoder.so
              > x86
                > libaacdecoder.so

how i can load libs in latest version of android M

i also tried

 System.loadLibrary("src/main/amn/armeabi/libaacdecoder.so");
        System.loadLibrary("src/main/amn/armeabi-v7a/libaacdecoder.so");
        System.loadLibrary("src/main/amn/mips/libaacdecoder.so");
        System.loadLibrary("src/main/amn/x86/libaacdecoder.so");
        System.loadLibrary("src/main/amn/aacdecoder-android-0.8.jar");

but nothings works :(

thank you in advance .. m waiting


Solution

  • I have fixed this problem for api 26 So:

    1- you need to implments this new library : https://github.com/hichemcesar24/AACDecoder

    2- you need to change in gradle I am using below this code:

    android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "0.8"
        group = 'com.spoledge.aacdecoder'
        version = '0.8-SNAPSHOT'
        ndk { stl "gnustl_static" }
    }
    
    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = []
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    
    task ndkBuild(type: Exec) {
       // def ndkDir =plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()
       def ndkDir = project.android.ndkDirectory.absolutePath
    
    
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine "$ndkDir/ndk-build.cmd", '-C', file('src/main/jni').absolutePath
        } else {
            commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath
        }
    }
    
    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }
    }
    

    3- change classpath of build gradle to :

     classpath 'com.android.tools.build:gradle:2.2.2'
    

    4- if have problem in gradle So you need to delete :

     def ndkDir = project.android.ndkDirectory.absolutePath
    

    and changed with this:

     def ndkDir =plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()