tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

"java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found" when running on Android Dynamic FeatureModule #624

Closed carlosandre-br closed 3 years ago

carlosandre-br commented 3 years ago

Description The library works perfectly in my environment, but when I try to run it on a dynamic module, I'm getting java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found.

Expected behavior Run the library in a dynamic feature module.

Current behavior The library crashes when it calls System.loadLibrary("mobileffmpeg");

Logs https://ghostbin.co/paste/9o4rt

Environment

Other In Debug mode the app works fine.

But when I installed as App Bundle, I got the error.

Steps I did:

  1. Create Android app with compileSdkVersion 29 and targetSdkVersion 29
  2. Create dynamic feature module in Android Studio
  3. Add the implementation group: 'com.arthenica', name: 'mobile-ffmpeg-min', version: '4.4.LTS' to the new module
  4. Generate a signed App Bundle (AAB)
  5. Install the base APK using the Android Bundle tool as following:

sudo java -jar bundletool-all-1.4.0.jar build-apks --local-testing --bundle /path/to/app-release.aab --output /path/to/output.apks

sudo java -jar bundletool-all-1.4.0.jar install-apks --apks /path/to/output.apks

  1. In the app, request a feature module installation
  2. After dynamic module installation, call long executionId = FFmpeg.executeAsync("-version", new ExecuteCallback() {...}); and it throw an error.

Additional Log after the module installation: https://ghostbin.co/paste/7rsj2

tanersener commented 3 years ago

There are similar issues created for UnsatisfiedLinkError recently. Have you looked at them?

carlosandre-br commented 3 years ago

Yes I did, but none of them referred to the problem with dynamic delivery specifically. I solved it by loading the libraries using SplitInstallHelper.loadLibrary(Context,String) after module installation. This way:

 @Override
    public void onStateUpdate(SplitInstallSessionState state) {
        if (state.sessionId() == sessionId) {
            switch (state.status()) {
                case INSTALLED:
                    statusText.setText("Installed - Feature is ready");
                    SplitInstallHelper.loadLibrary(this, "avutil");
                    SplitInstallHelper.loadLibrary(this, "swscale");
                    SplitInstallHelper.loadLibrary(this, "swresample");
                    SplitInstallHelper.loadLibrary(this, "avcodec");
                    SplitInstallHelper.loadLibrary(this, "avformat");
                    SplitInstallHelper.loadLibrary(this, "avfilter");
                    SplitInstallHelper.loadLibrary(this, "avdevice");
                    break;
            }
        }
    }
Thank you!
iamkdblue commented 3 years ago

@carlosandre-br Thanks for the answer

i am getting "java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found" @carlosandre-br I tried your code but it's not working for me! does FakeSplitInstallManagerFactory is necessary if you testing a dynamic feature module locally?

Version mobile-ffmpeg-audio - 4.4.LTS

carlosandre-br commented 3 years ago

Hello @iamkdblue!

It's not necessary to use FakeSplitInstallManagerFactory to test success cases.

I'm attaching a demo project that's working, please check DynamicDemo.zip and compare with yours.

iamkdblue commented 3 years ago

@carlosandre-br finally it solved now, Thank you so much, your project helps me a lot. You should put the above project on GitHub, it will help many people

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.