美文网首页
bintray关闭项目编译失败

bintray关闭项目编译失败

作者: 卓技卓品 | 来源:发表于2022-04-24 18:21 被阅读0次

问题

导入一个旧项目,在编译时失败:

Could not determine the dependencies of task ':app:compileDebugKotlin'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve androidx.room:room-common:[2.2.3].
Required by:
project :app > androidx.room:room-runtime:2.2.3
project :app > androidx.room:room-rxjava2:2.2.3
Failed to list versions for androidx.room:room-common.
Unable to load Maven meta-data from https://dl.bintray.com/relish-wang/maven/androidx/room/room-common/maven-metadata.xml.
Could not get resource 'https://dl.bintray.com/relish-wang/maven/androidx/room/room-common/maven-metadata.xml'.
Could not GET 'https://dl.bintray.com/relish-wang/maven/androidx/room/room-common/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

此时我们看到错误:Received status code 502 from server: Bad Gateway。
查询资料了解到,原来JCenter关闭了:jfrog关于bintray的更新,中文翻译:Jcenter服务即将关闭,改用mavenCentral
官方建议改成其他库,比如mavenCentral。但是并不是所有以来的开源项目都能够及时迁移到mavenCentral,同时也不是所有的版本都会迁移过去,所以就出现了编译错误。

解决

针对这种问题,我们只能更换镜像资源,在国内我们可以使用阿里云的镜像。比如我项目原来配置如下:

allprojects {
    repositories {
        mavenCentral()
        google()
        maven { url "https://jitpack.io" }
        maven { url "https://dl.bintray.com/relish-wang/maven/" }
    }
}

此时项目编译失败,错误如需求中展示。 此时我们更换成国内阿里镜像:

allprojects {
    repositories {
        mavenCentral()
        google()
        maven {
            url 'https://maven.aliyun.com/repository/public/'
        }
    }
}

此时再次编译项目,发现已经能够正常运行了。
有些项目在阿里镜像库中没有及时收录,可能编译继续出错,此时我们可以使用浏览器访问阿里云云效 Maven,查询看一下已经收录的版本,然后将依赖变更成对应的版本即可。
比如项目中依赖的implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:3.0.0'在使用时尚未收录,我们可以更改成其他版本implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'。 此时编译成功。

总结

因为镜像库可以理解成一个下载站,所以对他的维护需要大量的带宽和存储资源。而本身镜像库优势非盈利的开源项目,所以很多企业都慢慢的关闭或收窄。
当前国内用的比较多的开源库就是阿里云,除此之外还有:
华为云开源镜像站
网易开源镜像站

相关文章

网友评论

      本文标题:bintray关闭项目编译失败

      本文链接:https://www.haomeiwen.com/subject/pvqqyrtx.html