问题描述
Android Studio Arctic Fox Canary 8 开始警告 JCenter 已结束生命
Android Studio Arctic Fox Canary 8 started to warn that JCenter is at end of life
但我不能只删除 jcenter()
声明,因为它承载了很多 android 工件,这会导致 Could not resolve all artifacts
错误.解决此警告的正确方法是什么?
But I cannot just delete jcenter()
declarations since it hosts a lot of android artifacts, it would lead to Could not resolve all artifacts
error. What is the right way to solve this warning?
推荐答案
有一个文档部分描述了这个问题:JCenter 弃用和服务终止.您可以通过展开检查说明 (Ctrl+F1
) 来找到链接.文档指出:
There's a documentation section describing the problem: JCenter deprecation and end of service. You can find the link by expanding the inspection description (Ctrl+F1
). The documentation states:
JFrog,该公司维护许多 Android 项目使用的 JCenter 工件存储库,最近宣布弃用和即将停用 JCenter.根据公告,JCenter 将允许在 2022 年 2 月 1 日前下载现有工件.
在 JCenter 上发布工件的开发人员应该开始将他们的包迁移到新主机,例如作为 Maven 中心.
Developers who publish artifacts on JCenter should start migrating their packages to a new host, suchas Maven Central.
在不久的将来,我们将提供有关将 Android 项目从此页面上的 JCenter.
In the near future, we will provide additional information about migrating Android projects away fromJCenter on this page.
扩展检查说明(以及上面的文档)建议将 jcenter()
替换为 mavenCentral()
.实际上,JCenter 是 Maven Central 的超集,但是在您的项目使用的所有 JCenter 工件都被移动之前,这样的替换不会解决问题到 Maven 中心.
The expanded inspection description (as well as the documentation above) suggests to replace jcenter()
by mavenCentral()
. Acually JCenter is a superset of Maven Central, but such a replacement won't resolve the problem until all JCenter artifacts your project uses will be moved to Maven Central.
我认为最佳解决方案是等到您使用的库从 jcenter()
移出并尝试用 mavenCentral()
替换它.如果仍然缺少某些工件,请查看文档,它们可能被移到另一个存储库中,您也应该将其添加到 repositories
列表中.
I think the optimal solution would be to wait until the libraries you're using are moved from jcenter()
and try to replace it with mavenCentral()
. If some artifacts are still missing, take a look at the documentation, may be they are moved into another repository and you should add it to the repositories
list as well.
repositories {
google()
// jcenter() // <- removed
mavenCentral() // <- added
}
如果您是库作者,您应该迁移到另一个存储库,可能是 Maven Central.请注意,根据 JCenter 弃用公告仅允许在 2021 年 3 月 31 日之前提交新的提交.
If you're a library author you should migrate to another repo, probably it would be Maven Central. Note that according to the JCenter deprecation announcement new submissions are allowed only until March 31st 2021.
一些相关资源:
这篇关于“JCenter 已寿终正寝"android lint 警告,什么是替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!