我目前正在从我的Android应用程序中的ExoPlayer(com.google.android.exoplayer2版本2.19.1)迁移到Media3(1.1.1).中提供的迁移说明 official Android documentation.

我已经进行了必要的代码和依赖项更改,但在扩展我的XML布局中的androidx.media3.ui.PlayerView时遇到错误.具体地说,我收到以下错误:

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

并进一步


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
                                                                                                   

以下是我的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"/>

并添加了所有依赖项

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"

我还把这个加到了我的build.gradle上

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

如果有任何关于如何解决此问题并成功迁移到Media3的指导或建议,我将不胜感激.谢谢!

推荐答案

看起来你仍然在你的一个布局中使用com.google.android.exoplayer2.ui.DefaultTimeBar.

那么,你能试着在你的布局中把DefaultTimeBar更新到androidx.media3.ui.DefaultTimeBar吗?

Android相关问答推荐

Android Google Select 帐户总是会产生结果代码0

未解析的引用:背景 colored颜色

房间DB:UPSERT返回什么?

译码BLE血糖仪特征值

Android系统应用程序启用编程以太网网络共享

DocumentFile.canWrite()、DocumentFile.Existes()-使用本地内置手机存储(而不是云)时性能较差(占用太多CPU时间)

使用RecycleView和Diffutils时从列表中删除项目时出现问题

Modifer.Align()不适用于行/列/框中的文本.未解决的作用域实例错误

插入视图模型时,dagger 未命中绑定错误

如何禁用自动登录 google play games services android unity?

具有数据库和升级潜力的移动应用程序开发(Android)供朋友使用

列表更改时,RecyclerView 中的列表不会更新

Android CompanionDeviceManager 永远找不到任何附近的蓝牙设备

组成不重叠的元素

是否可以在 Kotlin 中为 mutableStateOf() 设置自定义设置器

从 Firebase 云存储中获取照片会导致 Android Jetpack Compose 闪烁

Kotlin Coroutines 会取代 AsyncTask 吗?

Android build gradle 文件版本代码自动递增

为什么按钮没有拉伸到屏幕边缘?

如何从构建的流对象中发出值