You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决ExoPlayer报错:AAPT: error: attribute fastforward_increment not found

问题诱因

该报错的核心原因是fastforward_increment、rewind_increment两个属性无法被项目识别,常见触发场景如下:

  • 依赖的ExoPlayer版本低于2.15.0:这两个属性是ExoPlayer 2.15.0版本才新增的UI控件属性,旧版本库中不存在对应的属性声明
  • ExoPlayer相关依赖版本不统一:核心库和UI库版本不一致,导致UI库是无对应属性的旧版本
  • XML布局未正确声明自定义命名空间,或使用了不支持该属性的旧版PlayerView控件
解决步骤
  • 统一ExoPlayer依赖版本,且升级到2.15.0及以上稳定版,推荐使用官方BOM管理版本避免版本不一致问题,配置示例如下(模块级build.gradle):
dependencies {
    // 引入BOM统一管理所有ExoPlayer依赖版本,此处以2.19.1为例,可替换为最新稳定版
    implementation "com.google.android.exoplayer:exoplayer-bom:2.19.1"
    // 后续引入ExoPlayer其他组件无需额外标注版本号
    implementation "com.google.android.exoplayer:exoplayer-core"
    implementation "com.google.android.exoplayer:exoplayer-ui"
}
  • 检查XML布局根节点,确认已添加自定义命名空间声明:
xmlns:app="http://schemas.android.com/apk/res-auto"
  • 将布局中的播放器控件替换为支持该属性的StyledPlayerView,属性配置示例如下:
<com.google.android.exoplayer2.ui.StyledPlayerView
    android:id="@+id/player_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:fastforward_increment="10000"
    app:rewind_increment="10000"
    app:show_buffering="when_playing"/>

注:两个时间属性的单位为毫秒,上述示例代表快进/快退步长为10秒。

  • 清理项目缓存后重新构建:依次点击Android Studio菜单栏 Build -> Clean Project、Build -> Rebuild Project 即可消除报错。

内容的提问来源于stack exchange,提问作者Kristian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 14:54:04