当前位置:   article > 正文

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

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





一、报错信息



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

报错信息 :

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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

在这里插入图片描述





二、解决方案



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 下载依赖时 , 从这些仓库中下载 ;

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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

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/" }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

4、检查网络


检查网络 ,

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

5、手动下载 Gradle 依赖


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

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号