I'm currently in the process of migrating from ExoPlayer (com.google.android.exoplayer2 version 2.19.1) to Media3 (1.1.1) in my Android app. I've followed the migration instructions provided in the official Android documentation.
I've made the necessary code and dependency changes, but I'm encountering an error when inflating the androidx.media3.ui.PlayerView in my XML layout. Specifically, I'm getting the following error:
android.view.InflateException: Binary XML file line #16 in
com.xxx.xx:layout/mpeg_player: Binary XML file line #16 in
com.xxxx.xx:layout/mpeg_player: Error inflating class
androidx.media3.ui.PlayerView
and further
Caused by: android.view.InflateException: Binary XML
file line #78 in com.xxx.xx:layout/exo_player_control_view:
Binary XML file line #78 in com.xxx.xx:layout/exo_player_control_view:
Error inflating class com.google.android.exoplayer2.ui.DefaultTimeBar
Caused by: android.view.InflateException: Binary XML file line #78 in com.xxx.xxx:layout/exo_player_control_view: Error inflating class com.google.android.exoplayer2.ui.DefaultTimeBar
Caused by: java.lang.ClassNotFoundException: com.google.android.exoplayer2.ui.DefaultTimeBar
here is my xml
<androidx.media3.ui.PlayerView
android:id="@+id/video_view"
app:show_buffering="always"
app:show_subtitle_button="true"
android:focusable="false"
app:use_controller="true"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
and added all dependencies
implementation 'androidx.media3:media3-exoplayer:1.1.1'
implementation 'androidx.media3:media3-exoplayer-dash:1.1.1'
implementation 'androidx.media3:media3-ui:1.1.1'
implementation "androidx.media3:media3-session:1.1.1"
also added this to my build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
I would appreciate any guidance or suggestions on how to resolve this issue and successfully migrate to Media3. Thank you!
Looks like you still using com.google.android.exoplayer2.ui.DefaultTimeBar
in one of your layouts.
So, can you try to update the DefaultTimeBar
to androidx.media3.ui.DefaultTimeBar
in your layout.