You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Lint警告‘JCenter is at end of life’的替代源及Android Studio Arctic Fox Canary 8下的解决方案

Hey there! Let's break down your JCenter-related questions clearly—this is such a common pain point for Android devs right now, so I’m glad you’re asking.

1. What’s the replacement for JCenter now that it’s end-of-life?

The official, widely adopted alternatives are:

  • Maven Central (mavenCentral()): This is the primary go-to replacement. Most popular Android libraries have migrated here, it’s maintained by the Sonatype team, and it’s the de facto standard for Java/Kotlin artifacts.
  • Google’s Maven Repository (google()): Essential for all Android-specific dependencies like Jetpack libraries, AndroidX, and Google Play Services.

These two repositories should cover nearly all your dependency needs moving forward.

2. How to fix the JCenter end-of-life warning without triggering "Could not resolve all artifacts" errors?

Deleting jcenter() directly breaks builds because many libraries haven’t fully migrated yet. Here’s the safe, step-by-step fix:

  1. Prioritize modern repositories first
    In your project’s settings.gradle (or root build.gradle for older Android Studio versions), list google() and mavenCentral() before jcenter(). This tells Gradle to check active, maintained repositories first, only falling back to JCenter if a dependency can’t be found elsewhere:

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            jcenter() // Keep this temporarily, but lower its priority
        }
    }
    
  2. Restrict JCenter to only necessary dependencies
    Instead of keeping a wide-open jcenter() declaration, limit it to only the dependency groups that haven’t migrated yet. For example, if you have a library com.legacy-library:old-sdk that’s only hosted on JCenter, modify the JCenter entry like this:

    jcenter() {
        content {
            includeGroup("com.legacy-library")
            // Add other specific groups here if needed
        }
    }
    

    This way, Gradle only uses JCenter for those specific dependencies, cutting down on unnecessary requests and reducing warning noise.

  3. Gradually migrate off JCenter

    • Run ./gradlew dependencies (or use Android Studio’s "Gradle > Tasks > android > androidDependencies" view) to list all your project’s dependencies and identify which ones are still pulling from JCenter.
    • For each of those dependencies, check the library’s official GitHub page or docs to see if they’ve released a version hosted on Maven Central or Google’s repo. Update your dependency declarations to use those migrated versions.
    • Once all dependencies are available from modern repositories, you can safely delete the jcenter() entry entirely.
  4. Handle edge cases
    If you encounter a library that truly hasn’t migrated anywhere else, you can host it locally (e.g., in a libs folder) or use a self-hosted Maven repository as a temporary workaround.


内容的提问来源于stack exchange,提问作者Valeriy Katkov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 08:52:39