今天早上编译 Android 程序 , 发现无法编译通过 ijkplayer 依赖无法正常下载 ;
项目中使用了如下依赖 :
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
上周还能运行 , 周末回来 , 周一无法运行 ;
记录下排查流程 ;
ijkplayer 远程仓库无法使用 , 在本地配置 ijkplayer 库 ;
一、jcenter 仓库问题
1、报错信息
编译后 , 先报 jcenter 仓库问题 , 该仓库已经停用
> Could not resolve tv.danmaku.ijk.media:ijkplayer-java:0.8.8.
> Could not get resource 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-java/0.8.8/ijkplayer-java-0.8.8.pom'.
完整报错信息 :
FAILURE: Build completed with 9 failures.
1: Task failed with an exception.
-
What went wrong:
Execution failed for task ':app:dataBindingMergeDependencyArtifactsDebug'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve tv.danmaku.ijk.media:ijkplayer-java:0.8.8.
Required by:
project :app
> Could not resolve tv.danmaku.ijk.media:ijkplayer-java:0.8.8.
> Could not get resource 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-java/0.8.8/ijkplayer-java-0.8.8.pom'.
> Could not GET 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-java/0.8.8/ijkplayer-java-0.8.8.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8.
Required by:
project :app
> Could not resolve tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8.
> Could not get resource 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-armv7a/0.8.8/ijkplayer-armv7a-0.8.8.pom'.
> Could not GET 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-armv7a/0.8.8/ijkplayer-armv7a-0.8.8.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve tv.danmaku.ijk.media:ijkplayer-exo:0.8.8.
Required by:
project :app
> Could not resolve tv.danmaku.ijk.media:ijkplayer-exo:0.8.8.
> Could not get resource 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-exo/0.8.8/ijkplayer-exo-0.8.8.pom'.
> Could not GET 'https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-exo/0.8.8/ijkplayer-exo-0.8.8.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 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.
==============================================================================
2、解决方案
报错中提示 https://jcenter.bintray.com/tv/danmaku/ijk/media/ijkplayer-java/0.8.8/ijkplayer-java-0.8.8.pom 无法访问 , 在浏览器中输入该网址 , 查看网站是否能访问 ;
直接将 根目录下 build.gradle 中的 buildscript 和 allprojects 下的 jcenter 仓库注释掉 , 这个仓库已经停止服务 , 无法访问 ;
注释之后 , 显示开始下载 ijkplayer 的依赖 , 等待一段时间 , 看是否能下载完毕 ;
继续下载 , 还是失败 ;
Failed to resolve: tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8 Show in Project Structure dialog Affected Modules: app
Failed to resolve: tv.danmaku.ijk.media:ijkplayer-exo:0.8.8
Show in Project Structure dialog
Affected Modules: app
Failed to resolve: tv.danmaku.ijk.media:ijkplayer-java:0.8.8
Show in Project Structure dialog
Affected Modules: app
二、查找并配置 ijkplayer 源
到 https://mvnrepository.com/ 网站中查询 Maven 依赖 ,
搜索 ijkplayer ,
点进去之后 , 发现有 三个仓库 可供下载 ;
点击 Repository 一栏中的 Spring Plugins 按钮 , 可以查看该仓库的地址 https://repo.spring.io/plugins-release/ ;
将该仓库配置到 根目录下的 build.gradle 中的 allprojects 中 ,
maven { url "https://repo.spring.io/plugins-release/" }
完整的配置如下 : 之前的 jcenter 已经被注释 ;
allprojects {
repositories {
google()
mavenCentral()
//jcenter() // Warning: this repository is going to shut down soon
// ijkplayer 仓库
maven { url "https://repo.spring.io/plugins-release/" }
}
}
三、手动在本地配置 ijkplayer 依赖库
参考在 https://blog.csdn.net/shulianghan/category_11697316.html 专栏中编译的 ijkplayer 依赖库版本 , 将编译后的依赖库导入到本地 ;
依赖库下载地址 : https://download.csdn.net/download/han1202012/85008881
将目录中的 ijkplayer-armv7a , ijkplayer-java , tools 目录 , 拷贝到 Android Studio 的根目录 ;
打开 根目录下的 build.gradle 目录 , 将其拷贝到 主应用的 根目录下的 build.gradle 中 , 最终可编译成功 ;
ext { compileSdkVersion = 25 buildToolsVersion = "25.0.3"
targetSdkVersion = 25 versionCode = 800800 versionName = "0.8.8"
}