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.
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.
Deleting jcenter() directly breaks builds because many libraries haven’t fully migrated yet. Here’s the safe, step-by-step fix:
Prioritize modern repositories first
In your project’ssettings.gradle(or rootbuild.gradlefor older Android Studio versions), listgoogle()andmavenCentral()beforejcenter(). 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 } }Restrict JCenter to only necessary dependencies
Instead of keeping a wide-openjcenter()declaration, limit it to only the dependency groups that haven’t migrated yet. For example, if you have a librarycom.legacy-library:old-sdkthat’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.
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.
- Run
Handle edge cases
If you encounter a library that truly hasn’t migrated anywhere else, you can host it locally (e.g., in alibsfolder) or use a self-hosted Maven repository as a temporary workaround.
内容的提问来源于stack exchange,提问作者Valeriy Katkov

