简体   繁体   English

Android Studio Gradle:请从您的构建脚本中删除 `jcenter()` Maven 存储库的用法/JCenter 已结束生命周期

[英]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 文件中删除它,然后它就可以工作了。

删除 jcenter()

Hope this will help希望这会有所帮助

  1. Go to App/Gradle Scripts/build.gradle (Project:---) Go 到App/Gradle Scripts/build.gradle (项目:---)
  2. Change the jcenter() on build script{} and in all project repositories.在构建脚本{} 和所有项目存储库中更改jcenter()
  3. and Sync now.并立即同步。

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.所以这里有两个问题。

  1. First, we need to move MavenCentral above jCenter in all projects首先,我们需要在所有项目中将 MavenCentral 移到 jCenter 之上

  2. 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.

相关问题 React-Native:''请从您的构建脚本中删除 `jcenter()` Maven 存储库的用法...'' - React-Native: ''Please remove usages of `jcenter()` Maven repository from your build scripts...'' 在 Android Studio 中使用 Jcenter 和 gradle - Using Jcenter with gradle in Android studio 在Gradle中禁用jCenter存储库 - Disable jCenter repository in Gradle Android Studio:结构是否从jcenter移至其他位置(行家) - Android Studio : Is the fabric moved from jcenter to some other location(maven) Gradle无法从Android Studio中的jcenter()解析依赖项类路径 - Gradle cannot resolve dependencies classpath from jcenter() in Android studio Android Studio 1.3 不适用于 jcenter() Android Repository - Android Studio 1.3 will not work with jcenter() Android Repository Android Studio 不会从 jCenter 或 Maven Central 导入依赖项 - Android Studio does not import dependency from jCenter or Maven Central 将Android库从JCenter发布到Maven Central - Publishing Android Library from JCenter to Maven Central “JCenter 寿命已尽” android lint 警告,替换是什么? - “JCenter is at end of life” android lint warning, what is the replacement? JCenter 弃用; 对 Gradle 和 Android 的影响 - JCenter deprecation; impact on Gradle and Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM