tanersener / flutter-ffmpeg

FFmpeg plugin for Flutter. Not maintained anymore. Superseded by FFmpegKit.
GNU Lesser General Public License v3.0
645 stars 132 forks source link

Crash on Android API Level 22 #153

Closed ariefwijaya closed 4 years ago

ariefwijaya commented 4 years ago

Description I've tried to use -tls package, especially "min-gpl-lts" to support API level below 24. Built has been success. But the app can't start and immediately close unexpectedly without showing any error.

Expected behavior The app start normally in API 21+ and able to execute a command.

Current behavior Build Success, and when the app has launched, it close immediately without showing anything. Just close. It worked well when I'm using Android with API 24. But as it explained in here https://github.com/tanersener/flutter-ffmpeg#23-lts-releases , So I can use API Level 21+ when I'm using -tls package.

My Depedency:

dependencies:
  flutter:
    sdk: flutter
  chewie: ^0.9.10
  camera: ^0.5.8+2
  visibility_detector: ^0.1.5
  flutter_lyric:
      git: git://github.com/ariefwijaya/flutter_lyric.git
  audio_recorder: ^1.0.2
  audioplayers: ^0.15.1
  flutter_cache_manager: ^1.4.0
  rxdart: ^0.24.1
  flutter_ffmpeg: ^0.2.10

my Build.gradle:

buildscript {
    ext.kotlin_version = '1.3.70'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
    project.evaluationDependsOn(':app')
}

ext {
      flutterFFmpegPackage  = "min-gpl-lts"
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Logs You can see the log when build the apk here Built Log

Here is the logcat in android studio when starting app

06-10 21:27:57.733 1818-1818/? W/Zygote: MzIsRooted false
06-10 21:27:57.737 1818-1818/? I/art: Late-enabling -Xcheck:jni
06-10 21:27:57.818 1818-1818/? D/ActivityThread: hoder:android.app.IActivityManager$ContentProviderHolder@39765a18,provider,holder.Provider:android.content.ContentProviderProxy@d67dc71
06-10 21:27:57.829 1818-1818/? D/Proxy: setHttpRequestCheckHandler
06-10 21:27:57.917 1818-1818/? D/AndroidRuntime: Shutting down VM
06-10 21:27:57.921 1818-1818/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.etramatech.karaoke_example, PID: 1818
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.etramatech.karaoke_example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.etramatech.karaoke_example-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libflutter.so"
        at java.lang.Runtime.loadLibrary(Runtime.java:366)
        at java.lang.System.loadLibrary(System.java:988)
        at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:120)
        at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:88)
        at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:48)
        at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:24)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5097)
        at android.app.ActivityThread.access$1600(ActivityThread.java:181)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1657)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5889)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
06-10 21:27:57.986 1818-1848/? I/ResourceExtractor: Resource version mismatch res_timestamp-1-1591799165557
06-10 21:27:58.134 1818-1818/? I/Process: Sending signal. PID: 1818 SIG: 9

Environment

[√] Flutter (Channel stable, v1.17.3, on Microsoft Windows [Version 10.0.18363.778], locale en-ID)
    • Flutter version 1.17.3 at C:\flutter
    • Framework revision b041144f83 (6 days ago), 2020-06-04 09:26:11 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
    • Android SDK at C:\Users\poalalipo\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 30.0.0-rc4
    • ANDROID_HOME = C:\Users\poalalipo\AppData\Local\Android\Sdk
    • ANDROID_SDK_ROOT = C:\Users\poalalipo\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 46.0.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code, 64-bit edition (version 1.45.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.21.1

[√] Connected device (1 available)
    • m1 note • 192.168.43.1:5555 • android-arm64 • Android 5.1 (API 22)

Other I hope I can use this command in API 22. Because my device is using it.

await _flutterFFmpeg.execute(
        '-i "${widget.videoPath}" -i "${widget.audioPath}" -i "$instrumentNewPath" -filter_complex amix=inputs=3:duration=first:dropout_transition=0 -strict experimental -b:v 800k -b:a 192k -vf fps="fps=29/1" -f mp4 "$resultPath"');

Thank you for help @tanersener

tanersener commented 4 years ago

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.etramatech.karaoke_example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.etramatech.karaoke_example-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libflutter.so"

Are you sure that this issue is about flutter_ffmpeg? The error message above complains about libflutter.so.

ariefwijaya commented 4 years ago

Yes, because it happened only when I add flutter_ffmpeg, otherwise it run expectedly.

Currently I should override this settings in my gradle as a temporary fix to avoid that error, but I think this is not a good idea.


ext {
      flutterFFmpegPackage  = "min-gpl-lts"
}

subprojects {
     **project.setProperty("target-platform", "android-arm")**
//Failed to start app if the target-platform like this
//  project.setProperty("target-platform", "android-x64")
     project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I also analyze the apk, in lib folder, only arm64-v8a folder that doesn't have libflutter.so .

lib\arm64-v8a\
lib\armeabi-v7a\
lib\x86\
lib\x86_64\

Is that because the gradle settings from flutter_ffmpeg plugin that cause exclude libflutter.so in x64 ?

Have you tried flutter run with the same package and API < 24 devices ?

tanersener commented 4 years ago

You have this error because Android thinks your application is a 32-bit application. And there are different reasons that can cause this. It is the result of something in your project settings. Why don't you try to run the test application under the example folder and and see yourself whether I tested the package on a API < 24 device or not?

ariefwijaya commented 4 years ago

I have already test it using the example folder also. The same result and the same error.

This is only happen when flutter_ffmpeg included in the project. When I remove flutter_ffmpeg from depedency, arm64-v8a folder come with libflutter.so and worked as well.

I think, you need to test in on API < 24 with 64-bit. or target your gradle to platform x64 and see whether the libflutter.so included in arm64-v8a folder using your environment, so we can compare our result. I believe this is because the gradle from flutter_ffmpeg that override my gradle settings. but I have no idea which part can cause of them.

tanersener commented 4 years ago

Can you share logcat output of example app crashing? It may include something that explains why it fails on your device.

Btw, which of the following dependencies has native libraries like flutter_ffmpeg? If none of them has, why don't you try to depend on another library which has native libraries inside and see whether it fails or not?

dependencies:
  flutter:
    sdk: flutter
  chewie: ^0.9.10
  camera: ^0.5.8+2
  visibility_detector: ^0.1.5
  flutter_lyric:
      git: git://github.com/ariefwijaya/flutter_lyric.git
  audio_recorder: ^1.0.2
  audioplayers: ^0.15.1
  flutter_cache_manager: ^1.4.0
  rxdart: ^0.24.1
  flutter_ffmpeg: ^0.2.10
ariefwijaya commented 4 years ago

Here is the only one logcat that I found, and no more logcat I can see, because the app failed to start.

06-10 21:27:57.733 1818-1818/? W/Zygote: MzIsRooted false
06-10 21:27:57.737 1818-1818/? I/art: Late-enabling -Xcheck:jni
06-10 21:27:57.818 1818-1818/? D/ActivityThread: hoder:android.app.IActivityManager$ContentProviderHolder@39765a18,provider,holder.Provider:android.content.ContentProviderProxy@d67dc71
06-10 21:27:57.829 1818-1818/? D/Proxy: setHttpRequestCheckHandler
06-10 21:27:57.917 1818-1818/? D/AndroidRuntime: Shutting down VM
06-10 21:27:57.921 1818-1818/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.etramatech.karaoke_example, PID: 1818
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.etramatech.karaoke_example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.etramatech.karaoke_example-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libflutter.so"
        at java.lang.Runtime.loadLibrary(Runtime.java:366)
        at java.lang.System.loadLibrary(System.java:988)
        at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:120)
        at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:88)
        at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:48)
        at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:24)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5097)
        at android.app.ActivityThread.access$1600(ActivityThread.java:181)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1657)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5889)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
06-10 21:27:57.986 1818-1848/? I/ResourceExtractor: Resource version mismatch res_timestamp-1-1591799165557
06-10 21:27:58.134 1818-1818/? I/Process: Sending signal. PID: 1818 SIG: 9

Btw, which of the following dependencies has native libraries like flutter_ffmpeg?

As I know, only flutter_ffmpeg use native libraries, and included in apk. Some of dependencies below only call native function via method channel:

If none of them has, why don't you try to depend on another library which has native libraries

inside and see whether it fails or not? The big problem is, I've tried the example repo from flutter_ffmpeg get the same error. And I've tried also using new projects and include only flutter_ffmpeg as my dependencies.

tanersener commented 4 years ago

Thanks but that logcat output is already included in your first post. I was asking for the logcat output of the example app. If you do have a change to repeat that test and capture the logcat output that would be nice.

The big problem is, I've tried the example repo from flutter_ffmpeg get the same error. And I've tried also using new projects and include only flutter_ffmpeg as my dependencies.

Unfortunately, I can't reproduce your issue. If I could then I would be sure that there is something wrong there. But since I don't see any problem in my tests then I'm asking you to test a few things that can help you to identify your problem. Because it looks like it is specific to your project/environment/device. If you don't want to test them then don't.

Btw, this is my logcat output.

com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: Loading flutter-ffmpeg.
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/mobile-ffmpeg: Loading mobile-ffmpeg.
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/mobile-ffmpeg: Loaded mobile-ffmpeg-min-gpl-arm64-v8a-4.3.1-lts-20200125.
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample D/mobile-ffmpeg: Callback thread started.
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: Loaded flutter-ffmpeg-android-arm64-v8a.
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: FFmpeg version: git-2020-01-25-fd11dd500
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: Platform: android-arm64-v8a
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: Old log level: INFO
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: New log level: INFO
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: Package name: min-gpl
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: External library: libvidstab
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: External library: x264
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: External library: x265
com.arthenica.flutter.ffmpeg.FlutterFFmpegExample I/flutter: External library: xvid
ariefwijaya commented 4 years ago

Hi @tanersener , I've tried it, and the output result is the same. Weird. I still have no idea about the problem. the problem doesnt happened in emulator. May be this problem only in spesific device, environment or conflict with another plugin , I do not know. But I will close this issue. Thank you for your time