fix(android): support Media3 1.9 LoadControl API#5016
Conversation
4d44dd6 to
72f0e54
Compare
|
when will this be merged ? |
Not sure about this, let use patch for fix the crash issue first |
There was a problem hiding this comment.
Pull request overview
This PR updates the Android implementation to be compatible with androidx.media3:1.9.0, addressing runtime NoSuchMethodError crashes caused by Media3 API changes when an app’s dependency graph resolves a newer Media3 version than react-native-video was compiled against.
Changes:
- Bump the library’s Media3 version to
1.9.0. - Update
ReactExoplayerView.RNVLoadControlto use the Media31.9.0DefaultLoadControlconstructor and avoid the removedgetAllocator()API. - Enable core library desugaring in the bare Android example (for builds involving Media3 IMA 1.9.x).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/bare/android/build.gradle | Adds core library desugaring configuration for the example Android app module. |
| android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java | Updates RNVLoadControl for the Media3 1.9 DefaultLoadControl API and allocator handling. |
| android/gradle.properties | Bumps the pinned Media3 version from 1.8.0 to 1.9.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| config.getMinBufferMs() != BufferConfig.Companion.getBufferConfigPropUnsetInt() | ||
| ? config.getMinBufferMs() | ||
| : DefaultLoadControl.DEFAULT_MIN_BUFFER_FOR_LOCAL_PLAYBACK_MS, | ||
| config.getMaxBufferMs() != BufferConfig.Companion.getBufferConfigPropUnsetInt() | ||
| ? config.getMaxBufferMs() |
| subprojects { subproject -> | ||
| if (subproject.name == "app") { | ||
| subproject.plugins.withId("com.android.application") { | ||
| subproject.android { | ||
| compileOptions { | ||
| coreLibraryDesugaringEnabled true | ||
| } | ||
| } | ||
|
|
||
| subproject.dependencies { | ||
| coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5") | ||
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
| subprojects { subproject -> | ||
| if (subproject.name == "app") { | ||
| subproject.plugins.withId("com.android.application") { | ||
| subproject.android { | ||
| compileOptions { | ||
| coreLibraryDesugaringEnabled true | ||
| } | ||
| } | ||
|
|
||
| subproject.dependencies { | ||
| coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5") | ||
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
hey! thanks for the PR. Can you clarify why desugaring is added here?
There was a problem hiding this comment.
This is required for the Android example app with Ads. After updating Media3 IMA to 1.9.0, the ads example needs core library desugaring enabled in the app module, otherwise the Android example ads build may fail on older Android API compatibility checks.
Summary
Fix an Android runtime crash on the v6 line when an app resolves
androidx.media3to1.9.0.RNVLoadControlwas compiled against Media31.8.0, but apps with other Android media/camera dependencies can resolve Media3 to1.9.0at runtime. Media31.9.0changed theDefaultLoadControlconstructor signature andgetAllocator()API, which can causeNoSuchMethodError.Motivation
Fixes #4895 (link)
Fixes #4900 (link)
This change is needed to keep
react-native-videov6 compatible with Android apps whose dependency graph resolves Media3 to1.9.0.Observed crash:
Changes
RNVideo_media3Versionfrom1.8.0to1.9.0.RNVLoadControlto use the Media31.9.0DefaultLoadControlconstructor.DefaultAllocatorand use it for memory-based buffering checks.Platforms affected
Type of change
Test plan
Verified locally on the
support/6.x.xbranch:bun installalso ran the existing build step successfully:Expected behavior: Android builds against Media3
1.9.0, andRNVLoadControlno longer references the removed Media31.8.0constructor or no-arggetAllocator()API.Checklist
skills/react-native-video/) to match.