This question is a subsequent thread following this other question of mine.
After finally managing to successfully building the apk file using gradle and cmake to integrate FFMPEG into an Android project I am facing a new exception which is thrown when calling System.loadLibrary
.
java.lang.UnsatisfiedLinkError: dlopen failed: library "libavutil.so.56" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
at java.lang.System.loadLibrary(System.java:1657)
at com.hmomeni.canto.activities.EditActivity.<init>(EditActivity.kt:26)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
This is the part of code which is causing the error:
class EditActivity : AppCompatActivity(), View.OnClickListener {
init {
System.loadLibrary("Canto")
}
...
}
I tried moving the .so
files inside the PROJECT/app/jniLibs
and then adding the following line to build.gradle
file to no avail.
sourceSets.main.jniLibs.srcDirs = ['./jniLibs/']
If you configure your jniLibs.srcDirs as below:
Then your path
app/jniLibs/ffmpeg/{ANDROID_ABI}/lib
is not correct and your.so
files won't be found and packaged by your build system.Try to make your jniLibs structure be as below:
Dont add
lib
behind{ANDROID_ABI}/
.---Edit---
Maybe you should try to build your ffmpeg with option
--disable-asm
and-fPIC
to have a binary without text relocation. See here https://stackoverflow.com/a/39965908/8034839, but it looks there still some issue with NEON.Another discussion for your information: https://stackoverflow.com/a/50207091/8034839