android - "JCenter is at end of life"android lint 警告,替换是什么?

标签 android android-studio android-gradle-plugin

Android Studio北极狐金丝雀8开始警告JCenter is at end of life enter image description here
但我不能只删除jcenter()声明,因为它承载了很多 android 工件,它会导致 Could not resolve all artifacts错误。解决此警告的正确方法是什么?

最佳答案

有一个描述问题的文档部分:JCenter deprecation and end of service .您可以通过展开检查说明 (Ctrl+F1) 找到该链接。该文档指出:

JFrog, the company that maintains the JCenter artifact repository used by many Android projects, recently announced the deprecation and upcoming retirement of JCenter. According to the announcement, JCenter will allow downloads of existing artifacts until February 1, 2022.

Developers who publish artifacts on JCenter should start migrating their packages to a new host, such as Maven Central.

In the near future, we will provide additional information about migrating Android projects away from JCenter on this page.


扩展的检查说明(以及上面的文档)建议替换 jcenter()通过 mavenCentral() .实际上,JCenter 是 Maven Central 的超集,但是在您的项目使用的所有 JCenter 工件都被移到 Maven Central 之前,这样的替换不会解决问题。
我认为最佳解决方案是等到您正在使用的库从 jcenter() 移出。并尝试将其替换为 mavenCentral() .如果仍然缺少某些工件,请查看文档,可能它们已移至另一个存储库,您应该将其添加到 repositories也列出来。
repositories {
    google()

//  jcenter()       // <- removed
    mavenCentral()  // <- added
}
如果您是库作者,您应该迁移到另一个 repo,可能是 Maven Central。请注意,根据 JCenter deprecation announcement新的提交只允许在 2021 年 3 月 31 日之前提交。
一些相关资源:
  • The jCenter & Bintray is Shutting Down. Now What?
  • Migrating away from JCenter
  • 关于android - "JCenter is at end of life"android lint 警告,替换是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66400264/

    相关文章:

    android - 滑动刷新后删除项目不更新 RecyclerView

    android - 我们如何获得 Composable 在屏幕中的位置/大小?

    java - Activity 不是 Android Studio 中的封闭类

    Android Studio v1.2.0 启动错误: java. lang.NullPointerException

    gradle - 安卓 : run sonarRunner from gradle

    android - app:transformDexArchiveWithExternalLibsDexMergerForDebug:无法合并Dex Android Studio 3.0.1

    java - 操作栏选项卡必须有回调 addTab 错误

    android - 错误 :compileSdkVersion android-21 requires compiling with JDK 7 - windows

    android - 为什么用户运行 gradlew 的位置会影响输出?

    java - 下载管理器 - 设置文件扩展名而无需硬编码