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

引入ExoPlayer2.8.4适配Toro库却下载2.13.3版本如何解决

问题原因

你当前的依赖分辨率策略仅配置在bundle块内部,该配置仅对App Bundle打包场景生效,常规APK构建不会触发。同时其他第三方依赖(如Giphy SDK、自动播放组件等)传递引入了更高版本的ExoPlayer,Gradle默认会优先使用更高版本的依赖,导致你声明的2.8.4版本被覆盖。

解决方案

步骤1:修正全局依赖分辨率策略

打开app模块的build.gradle,将原本写在bundle块内的configurations.all挪到android块外部(dependencies块之前即可),同时添加所有ExoPlayer子模块的强制版本约束,修改后的代码结构如下:

android {
    compileSdkVersion 31
    // 保留你原有android块内的所有配置,仅删除bundle内部的configurations.all块
    buildTypes {
        // 原有release配置不变
        release {
            // ...
        }
        packagingOptions {
            // ...
        }
        bundle {
            language {
                enableSplit = false
            }
            // 删除原本这里的configurations.all配置
        }
    }
}

// 新增全局依赖分辨率配置
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
        // 强制所有ExoPlayer相关组件统一使用2.8.4版本
        force 'com.google.android.exoplayer:exoplayer:2.8.4'
        force 'com.google.android.exoplayer:exoplayer-core:2.8.4'
        force 'com.google.android.exoplayer:exoplayer-ui:2.8.4'
        force 'com.google.android.exoplayer:exoplayer-dash:2.8.4'
        force 'com.google.android.exoplayer:exoplayer-hls:2.8.4'
        force 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.8.4'
    }
}

dependencies {
    // 保留你原有所有依赖配置不变
}

步骤2:重新构建项目

修改完成后执行以下操作:

  • 点击Android Studio菜单栏的 File -> Invalidate Caches / Restart 失效缓存并重启
  • 重启后执行 Build -> Clean Project 清理旧构建产物
  • 最后执行 Rebuild Project 重新构建即可生效

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 18:15:05