0

I was wondering how do I include libyuv library to my Android Studio Project. I have the "libyuv_static.a" file which is a pre-compiled binary file but I did everything to include it in my project. I created a folder inside src/main named jniLibs and puted the binary file inside the folder but in runtime it doesn't load the library and it gives me this:

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load libyuv2rgb from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.myproject-1.apk,libraryPath=/data/app-lib/com.example.myproject-1]: findLibrary returned null

. Could someone please share his/her experience.

Nav Nav
  • 169
  • 1
  • 20

2 Answers2

1

In order to include a native library into an Android project, you have to get a .so file (shared library), not a .a (static library).

ie. you should end up with src/main/jniLibs/<abi>/libyuv_shared.so with <abi> being armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64 (any architecture your app and lib support).

ph0b
  • 14,353
  • 4
  • 43
  • 41
1

There is an Android package now: https://github.com/crow-misia/libyuv-android, installable from mavenCentral:

dependencies {
    implementation 'io.github.crow-misia.libyuv:libyuv-android:0.25.0'
}

For usage see https://github.com/crow-misia/libyuv-android/blob/main/sample/src/main/java/app/MainActivity.kt

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121