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?
If you're a library author you should migrate to another repo, probably it would be 玛文中心. Note that according to the JCenter deprecation announcement new submissions are allowed only until March 31st 2021.
If you attempt to remove jcenter() completely today from your Android project, you may get the following error.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
Required by:
project : > com.android.tools.build:gradle:4.1.2 > com.android.tools.build:builder:4.1.2 > com.android.tools:sdk-common:27.1.2
出现这个错误的原因是 Android Core 依赖项仍然需要 JCenter。
Android Studio 4.1.2 and AGP (Android Gradle Plugin) still require a version of a dependency (trove4j) that is only on JCenter.
这个问题在 AGP4.2.0中已经解决了,但是仍处于测试阶段,需要 Android Studio 4.2测试版或更新版本。