[英]Android Studio Gradle: Please remove usages of `jcenter()` Maven repository from your build scripts / JCenter is at end of life
In Android Studio 4.2 there is a warning:在 Android Studio 4.2 中有一个警告:
buildscript {
ext.kotlin_version = '1.5.0'
repositories {
google()
//jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
//jcenter()
mavenCentral()
}
}
If I remove jcenter()
then it can't find some dependencies of my app project:如果我删除
jcenter()
那么它找不到我的应用程序项目的一些依赖项:
> Could not find org.koin:koin-core:2.0.1.
Required by:
project :app
> Could not find org.koin:koin-androidx-scope:2.0.1.
Required by:
project :app
> Could not find org.koin:koin-androidx-viewmodel:2.0.1.
Required by:
project :app
> Could not find com.google.ads.mediation:chartboost:8.1.0.0.
Required by:
project :app
In replace of jcenter()
I added mavenCentral()
代替
jcenter()
我添加了mavenCentral()
Move mavenCentral()
above jcenter()
.将
mavenCentral()
jcenter()
。
do a clean/build on your project.对您的项目进行清理/构建。
comment out jcenter()
注释掉
jcenter()
By moving mavenCentral()
above jcenter()
, mavenCentral()
now becomes the primary repository for all non Google artifacts.通过将 mavenCentral() 移到
mavenCentral()
上方, jcenter()
mavenCentral()
现在成为所有非 Google 工件的主要存储库。 By doing a clean and build, all artifacts are now moved to mavenCentral()
.通过进行清理和构建,所有工件现在都移至
mavenCentral()
。
I had to look this up and tried it.我不得不查找并尝试了它。 I went from all heck breaking loose after I removed
jcenter()
to being able to build my final project for school again.在我删除
jcenter()
之后,我彻底摆脱了束缚,从而能够再次为学校构建我的最终项目。
For koin, change the group id from org.koin
to io.insert-koin
- the latter is published on maven central.对于 koin,将组 id 从
org.koin
更改为io.insert-koin
- 后者发布在 maven 中央。
For chartboost, you can use the following repo:对于 chartboost,您可以使用以下 repo:
maven {
url "https://dl.bintray.com/google/mobile-ads-adapters-android/"
}
Also note that there are newer versions such as koin 2.2.2 / 3.0.1 and chartboost 8.2.0.0.另请注意,还有更新的版本,例如 koin 2.2.2 / 3.0.1 和 chartboost 8.2.0.0。 Older versions are likely not republished in non-jcenter repos.
旧版本可能不会在非 jcenter 存储库中重新发布。
mvnrepository is a good service for locating packages. mvnrepository是一个很好的定位包的服务。
just commenting out jcenter() will help, mavencentral() is already above jcenter.只是注释掉 jcenter() 会有所帮助,mavencentral() 已经在 jcenter 之上。
Locate all build.gradle
files in your project folder tree, open them and replace jcenter()
by mavenCentral()
.在项目文件夹树中找到所有
build.gradle
文件,打开它们并将jcenter()
替换为mavenCentral()
。 It works for me most of the time.大多数时候它对我有用。
It is interesting that the AndroidStudio project template still adds the ref to jcenter() to gradle, but then as soon as the project attempts to build it requests that you remove it.有趣的是,AndroidStudio 项目模板仍然将 jcenter() 的引用添加到 gradle,但是一旦项目尝试构建它,就会要求您将其删除。
I just delete it from the gradle file and then it works.我只是从 gradle 文件中删除它,然后它就可以工作了。
Hope this will help希望这会有所帮助
jcenter()
on build script{} and in all project repositories.jcenter()
。 This is how it looklike before.这是以前的样子。
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and after.之后。
buildscript {
repositories {
google()
mavencentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
}
}
allprojects {
repositories {
google()
mavencentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So there are two issues here.所以这里有两个问题。
First, we need to move MavenCentral above jCenter in all projects首先,我们需要在所有项目中将 MavenCentral 移到 jCenter 之上
Second, Android build tools version need to upgraded to 4.2.0 and above.二、Android构建工具版本需要升级到4.2.0及以上。 As Android internal build tool dependencies are going to jCenter
由于 Android 内部构建工具依赖项将转到 jCenter
dependencies { classpath("com.android.tools.build:gradle:4.2.0") }依赖项{类路径(“com.android.tools.build:gradle:4.2.0”)}
It should work它应该工作
This might help someone.这可能会帮助某人。
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
...
}
}
I used this to resolve:我用它来解决:
> Could not find com.github.parse-community.Parse-SDK-Android:parse:1.26.0.
Required by:
project :app
I got the same error, while i was using the Android Studio Artic Fox Beta - 3
but after change Android Studio as Canary Build
the error gone我遇到了同样的错误,当我使用 Android Studio
Artic Fox Beta - 3
但在将 Android Studio 更改为Canary Build
之后,错误消失了
The solution I did was to change build:gradle version:我所做的解决方案是更改 build:gradle 版本:
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
The solution is simpe just Locate build.gradle and replace jcenter() by mavenCentral() .解决方案很简单,只需找到build.gradle并将jcenter()替换为mavenCentral() 。
good luck祝你好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.