Flutter app crashes when video_player loads HLS video

Issue

When loading http://static.france24.com/live/F24_EN_LO_HLS/live_web.m3u8 using Flutter’s videoplayer the app crashes, but if I load https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4 it does not crash.. When it crashes it gives the following error:

I/ExoPlayerImpl(25192): Init c3a7b4 [ExoPlayerLib/2.11.5] [generic_x86, Android SDK built for x86, Google, 29]
E/flutter (25192): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/exoplayer2/source/ads/AdsMediaSource$MediaSourceFactory;
E/flutter (25192):  at io.flutter.plugins.videoplayer.VideoPlayerPlugin.create(VideoPlayerPlugin.java:119)
E/flutter (25192):  at io.flutter.plugins.videoplayer.Messages$VideoPlayerApi$2.onMessage(Messages.java:285)
E/flutter (25192):  at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:187)
E/flutter (25192):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (25192):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/flutter (25192):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (25192):  at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (25192):  at android.os.Looper.loop(Looper.java:174)
E/flutter (25192):  at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (25192):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (25192):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (25192):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/flutter (25192): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.exoplayer2.source.ads.AdsMediaSource$MediaSourceFactory" on path: DexPathList[[zip file "/data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86, /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
E/flutter (25192):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/flutter (25192):  at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/flutter (25192):  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/flutter (25192):  ... 12 more
E/flutter (25192): 
F/flutter (25192): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env). 
F/libc    (25192): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 25192 (ample.opengames), pid 25192 (ample.opengames)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys'
Revision: '0'
ABI: 'x86'
Timestamp: 2020-07-13 17:41:30+0100
pid: 25192, tid: 25192, name: ample.opengames  >>> com.example.opengames <<<
uid: 10144
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env). 
'
    eax 00000000  ebx 00006268  ecx 00006268  edx 00000006
    edi e5ec333e  esi ffc54b30
    ebp e9179ad0  esp ffc54ad8  eip e9179ad9
backtrace:
      #00 pc 00000ad9  [vdso] (__kernel_vsyscall+9)
      #01 pc 00092328  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
      #02 pc 000ad651  /apex/com.android.runtime/lib/bionic/libc.so (abort+193) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
      #03 pc 011c5cb1  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #04 pc 011b26e7  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #05 pc 011b0480  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #06 pc 01219191  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #07 pc 011c40c3  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #08 pc 011c6a09  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #09 pc 011c694e  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #10 pc 011ccb5a  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #11 pc 011ccb88  /data/app/com.example.opengames-UANE4n_Utna2P3c8SCDnRg==/lib/x86/libflutter.so (BuildId: a29ce163d16aaa44ca6f2b37a93309f890237d82)
      #12 pc 00018487  /system/lib/libutils.so (android::SimpleLooperCallback::handleEvent(int, int, void*)+39) (BuildId: 288ba3aff5b46dbd7e74be954af88b83)
      #13 pc 00019414  /system/lib/libutils.so (android::Looper::pollInner(int)+1044) (BuildId: 288ba3aff5b46dbd7e74be954af88b83)
      #14 pc 00018f4e  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+62) (BuildId: 288ba3aff5b46dbd7e74be954af88b83)
      #15 pc 0013299b  /system/lib/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long long, int)+59) (BuildId: 6ceb9761bceb97a18c92f8a4b7072247)
      #16 pc 002b86f8  /system/framework/x86/boot-framework.oat (art_jni_trampoline+136) (BuildId: ff6ec03dd8445d20788424c92ba8ea28ad0f54f4)
      #17 pc 0200bb56  /memfd:/jit-cache (deleted) (android.os.MessageQueue.next+230)
      #18 pc 02043450  /memfd:/jit-cache (deleted) (android.os.Looper.loop+336)
      #19 pc 00145984  /apex/com.android.runtime/lib/libart.so (art_quick_osr_stub+36) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #20 pc 0039d871  /apex/com.android.runtime/lib/libart.so (art::jit::Jit::MaybeDoOnStackReplacement(art::Thread*, art::ArtMethod*, unsigned int, int, art::JValue*)+2097) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #21 pc 0068ef65  /apex/com.android.runtime/lib/libart.so (MterpMaybeDoOnStackReplacement+197) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #22 pc 0013d375  /apex/com.android.runtime/lib/libart.so (MterpHelpers+294) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #23 pc 0031a13c  /system/framework/framework.jar (android.os.Looper.loop+1076)
      #24 pc 00684f6c  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+1260) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #25 pc 001389a1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #26 pc 0018945e  /system/framework/framework.jar (android.app.ActivityThread.main+194)
      #27 pc 002f8e0a  /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.12194892193087984976+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #28 pc 002ffcc5  /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+181) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #29 pc 0066fbd9  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+1209) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #30 pc 0014503d  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+77) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #31 pc 0013e9a2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+418) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #32 pc 00149a7a  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #33 pc 0055a513  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+99) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #34 pc 0055c32f  /apex/com.android.runtime/lib/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned int)+1327) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #35 pc 004c9153  /apex/com.android.runtime/lib/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+83) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #36 pc 000c6bf8  /system/framework/x86/boot.oat (art_jni_trampoline+168) (BuildId: 7913dbaef2e8d9971cb7619ef0d566987f8326a7)
      #37 pc 0013e7d2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+338) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #38 pc 00149a69  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+281) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #39 pc 00332502  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+386) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #40 pc 0032c19c  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+988) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #41 pc 0068186d  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+989) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #42 pc 00138821  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #43 pc 0034cd36  /system/framework/framework.jar (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+22)
      #44 pc 002f8e0a  /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.12194892193087984976+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #45 pc 002ffcc5  /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+181) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #46 pc 0066fbd9  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+1209) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #47 pc 0014503d  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+77) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #48 pc 00998b08  /system/framework/x86/boot-framework.oat (com.android.internal.os.ZygoteInit.main+1816) (BuildId: ff6ec03dd8445d20788424c92ba8ea28ad0f54f4)
      #49 pc 0013e9a2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+418) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #50 pc 00149a7a  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #51 pc 0055a513  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+99) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #52 pc 0055a1ae  /apex/com.android.runtime/lib/libart.so (art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, char*)+430) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #53 pc 004305cd  /apex/com.android.runtime/lib/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+893) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #54 pc 003d93bf  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, char*, art::Primitive::Type, art::InvokeType)+2847) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #55 pc 003c7509  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+73) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
      #56 pc 000b25fe  /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+62) (BuildId: 6ceb9761bceb97a18c92f8a4b7072247)
      #57 pc 000b628a  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+794) (BuildId: 6ceb9761bceb97a18c92f8a4b7072247)
      #58 pc 00003632  /system/bin/app_process32 (main+1490) (BuildId: b7a60bc7d078521421fd5a8d201915ae)
      #59 pc 000898e8  /apex/com.android.runtime/lib/bionic/libc.so (__libc_init+120) (BuildId: 76290498408016ad14f4b98c3ab6c65c)

This is the output of flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18362.900], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    X Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 3.6)
[√] VS Code (version 1.47.0)
[√] Connected device (1 available)

And in my pubspec.yaml I have video_player: ^0.10.11+2.

Can you help me figure out what’s going on?

Solution

basically the solution is to add an android dependency that’s opt-in for exoplayer. Either you or the lib author should do it.

At this moment I’m not sure if it’s you or them inserting ads (In-Media-Advertising? sic), or if there’s some sort of video_player_ima dependency out there.

A quick fix for you is add this to android/app/build.gradle in the dependencies section. But it should really be done in either video_player or a more appropriate lib.
implementation("com.google.android.exoplayer:extension-ima:<insert version here>")
make sure to match version, get a peek at the other exoplayer deps with

cd android  
./gradlew :app:dependencies

Edit: Seems like exoplayer eliminated the class AdsMediaSource$MediaSourceFactory between version 2.10 and 2.11.

Talking in private with @joao it’s not clear how he solved the problem. But it came from the fact that he was using both flutter plugin video_player with a dependency to exoplayer 2.9 and media_info with a dependency to 2.11.

Cross referencing the issue I opened on exoplayer to fix this cleanly https://github.com/google/ExoPlayer/issues/7638

Edit2:
After some investigation, it’s confirmed that for the reasons in edit1, you shouldn’t have exoplayer mixed versions. From issue 7638:

If you see gradle dependency resolution doing something like this com.google.android.exoplayer:exoplayer-core:2.9.6 -> 2.11.5 (*) then there is a risk things won’t work.

Edit3:
We got official answer from exoplayer team recommending pinning down the version each flutter plugin uses. The expectation is that it will fail at compile time.

Answered By – Fabio

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *