google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

NoClassDefFoundError Mp4Extractor in Android 5.X and 6.X versions #8182

Closed idish closed 3 years ago

idish commented 3 years ago

[REQUIRED] Issue description

Trying to prepare a media file causes a NoClassDefFoundError fatal crash on (seemingly all) Android 5.X and Android 6.X devices. I'm able to reproduce that crash with an Android 6.0 emulator, but not on 7.0 + as expected. Min api is 21, target API level is 29.

[REQUIRED] A full bug report captured from the device

E/LoadTask: Unexpected error loading stream java.lang.NoClassDefFoundError: com.google.android.exoplayer2.extractor.mp4.-$$Lambda$Mp4Extractor$IP-_bKEryH3151zsYMHu9R1OlAQ at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.processMoovAtom(Mp4Extractor.java:418) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.processAtomEnded(Mp4Extractor.java:381) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:372) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:195) at com.google.android.exoplayer2.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127) at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1046) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

[REQUIRED] Version of ExoPlayer being used

version: 2.12.1

[REQUIRED] Device(s) and version(s) of Android being used

Android 5.X, Android 6.X devices

kim-vde commented 3 years ago

Did you enable Java 8 support? Are you importing the extractors library with the same ExoPlayer version as the core library? Does the crash also occur in our demo app?

See also #7954.

idish commented 3 years ago

@kim-vde Yes, JAVA 8 is enabled. Yes, I'm using ExoPlayer as the following, non locally: def exoplayer_version = "2.12.1" implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version" implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"

There's no crash on demo app. I've looked at https://github.com/google/ExoPlayer/issues/7954 though it didn't help much :(

kim-vde commented 3 years ago

I am afraid I can't help more if I can't reproduce.

You could try to modify the demo app to reproduce your problem and indicate what you have changed. But, as written in this comment, this is more likely to be something specific about the way your particular app is being built.

marlon-br commented 3 years ago

i see the same issue on Android 6.0 devices

idish commented 3 years ago

Alright, so I managed to isolate the core cause of this crash. Seems as the following line in the build.gradle file causes a crash in Android 5.X and 6.X devices: apply plugin: 'de.jjohannes.missing-metadata-guava'

I added it as it was supposed to fix some build error while having version 12.2.0 of ExoPlayer. Following this comment (implementing suggestion #2): https://github.com/google/ExoPlayer/issues/7905#issuecomment-692637059

That issue has been resolved in the latest version (12.2.1), so we can just remove that plugin without any side effects:

Switch Guava dependency from implementation to api (#7905, #7993).

Thank you guys for your help! I will update if anything goes wrong regarding this issue.