前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【错误记录】Android 编译报错 ( Could not resolve com.google.android.exoplayer:exoplayer:r | 依赖下载失败通用解决方案总结 )

【错误记录】Android 编译报错 ( Could not resolve com.google.android.exoplayer:exoplayer:r | 依赖下载失败通用解决方案总结 )

作者头像
韩曙亮
发布2024-04-20 08:44:45
680
发布2024-04-20 08:44:45
举报

一、报错信息

编译 Android Studio 项目时 , 报如下错误 , 下载依赖库失败 ;

报错信息 :

代码语言:javascript
复制
Execution failed for task ':ijkplayer-exo:generateDebugRFile'.
> Could not resolve all files for configuration ':ijkplayer-exo:debugCompileClasspath'.
   > Could not resolve com.google.android.exoplayer:exoplayer:r1.5.11.
     Required by:
         project :ijkplayer-exo
      > Could not resolve com.google.android.exoplayer:exoplayer:r1.5.11.
         > Could not get resource 'https://raw.githubusercontent.com/Pgyer/analytics/master/com/google/android/exoplayer/exoplayer/r1.5.11/exoplayer-r1.5.11.pom'.
            > Could not HEAD 'https://raw.githubusercontent.com/Pgyer/analytics/master/com/google/android/exoplayer/exoplayer/r1.5.11/exoplayer-r1.5.11.pom'.
               > raw.githubusercontent.com

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

二、解决方案

Gradle 下载 依赖库 出现问题 , 按照下面的步骤 进行操作检查 ;

1、检查依赖库是否存在

ExoPlayer 是 Google 提供的一个在 Android 平台上的媒体播放器 , 它支持多种媒体格式和流媒体协议 ;

ijkplayer-exo 是 BliBli 对 Google 的 ExoPlayer 播放器的封装 , 通过封装 ExoPlayer,ijkplayer-exo 使得开发者能够在使用 ijkplayer 框架的同时,也能利用 ExoPlayer 的特性和功能 ;

通过在网络上进行搜索 , 确定 com.google.android.exoplayer:exoplayer 软件包是否存在 , 这是 https://github.com/google/ExoPlayer 的 GitHub 地址 ;

2、检查版本号是否正确

上述报错信息是 " Could not resolve com.google.android.exoplayer:exoplayer:r1.5.11. " 下载失败 , 这里就要确认 r1.5.11 版本号是否存在 ;

https://github.com/google/ExoPlayer/tags 页面 , 确认版本号是否存在 ;

3、检查仓库地址配置 ( 本案例的解决方案 )

确保配置的 Maven 仓库地址正确 ;

在 根目录下的 build.gradle 文件中配置的 allprojects / repositories 配置 就是 Maven 仓库地址 , 比如 jcenter() 或 mavenCentral() , 以便 Gradle 下载依赖时 , 从这些仓库中下载 ;

代码语言:javascript
复制
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

在本案例中 , 添加了 ijkplayer 仓库 , 解决了上述问题 ;

代码语言:javascript
复制
allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        
        // ijkplayer 仓库
        maven { url "https://repo.spring.io/plugins-release/" }
        maven { url "https://repository.mulesoft.org/nexus/content/repositories/public/" }
        maven { url "https://dl.bintray.com/bilibili/maven/" }
    }
}

4、检查网络

检查网络 ,

  • 首先 , 确保基本的网络联通 , 可以正常访问网络 ;
  • 然后 , 再看 Maven 仓库的地址是否被屏幕 , 可能需要挂梯子进行下载 ;

5、手动下载 Gradle 依赖

参考 下一篇博客 【错误记录】Android 编译报错 ( Could not resolve xxx | 手动下载依赖库并进行本地配置 Gradle 依赖的解决方案 ) ;

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2024-04-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、报错信息
  • 二、解决方案
    • 1、检查依赖库是否存在
      • 2、检查版本号是否正确
        • 3、检查仓库地址配置 ( 本案例的解决方案 )
          • 4、检查网络
            • 5、手动下载 Gradle 依赖
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档