0

I've an android app using IJKPlayer with ffmpeg*.so libraries. In a small test app, IJKPlayer libraries are references like this:

apply plugin: 'com.android.library'

android {
    // http://tools.android.com/tech-docs/new-build-system/tips
    //noinspection GroovyAssignabilityCheck
    compileSdkVersion rootProject.ext.compileSdkVersion
    //noinspection GroovyAssignabilityCheck
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion 25
        targetSdkVersion rootProject.ext.targetSdkVersion
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets.main {
        jniLibs.srcDirs 'src/main/libs'
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
    }
}

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

apply from: new File(rootProject.projectDir, "tools/gradle-on-demand.gradle");

This works fine with Android Studio 3.2.1. After doing nothing else then opening the project with Android Studio 4.1.2 and building/running it, the app fails with error:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.nvp.test.nvptest-N7MgBlkuRYXx_vQKF6j4jw==/base.apk"],nativeLibraryDirectories=[/data/app/com.nvp.test.nvptest-N7MgBlkuRYXx_vQKF6j4jw==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libijkffmpeg.so"

Any idea why? Looking at the error message, are these the directories, where android searches the libraries: /lib/arm64, /system/lib64, /system/vendor/lib64 ?

In this case it must fail, because the libraries are stored under /lib/armeabi-v7a. What must be done to make android searching this path? Why doest it work with 3.2.1, then?

Any hints are welcome.

Harry Developer
  • 260
  • 1
  • 3
  • 15
  • Note that it also looks in `/data/app/com.nvp.test.nvptest-N7MgBlkuRYXx_vQKF6j4jw==/lib/arm64`, not just in the system paths. As for why it stopped working, there could be several reasons. We don't really know enough about your particular project to say for sure. For example, maybe the default for `abiFilters` changed so that it now includes `arm64-v8a` and one or more (but not all) of your libraries have `arm64-v8a` versions. You must provide all libraries for every ABI that you want to support. – Michael Mar 29 '21 at 13:07
  • Thanks for your reply. I only have v7a libraries. Can I set an ABI filter, manually? – Harry Developer Mar 29 '21 at 13:19
  • Sure, you can add `ndk.abiFilters 'armeabi-v7a'` inside the `defaultConfig {}` block. But keep in mind that you won't be able to publish the app on Google Play if it only includes 32-bit libraries. – Michael Mar 29 '21 at 13:28
  • I've added `ndk { abiFilters 'armeabi-v7a' }` Doesn't help. It's still looking in the arm64 folders, only. – Harry Developer Mar 30 '21 at 06:55
  • It looks like there is a difference when running the app from within android studio or installing it as an APK. Does 4.1.2 have the instant run feature enabled? I didn't find it in the settings. Is there a similar thing which could cause trouble with external libraries? – Harry Developer Mar 30 '21 at 12:57

1 Answers1

0

I've created a new project from scratch and moved it from android studio 3.2.1 to 4.1.2. Now it works. Hence, the problem must be hidden somewhere in the android version chaos.

Harry Developer
  • 260
  • 1
  • 3
  • 15