简体   繁体   English

找不到 com.android.tools.build:gradle:4.4

[英]Could not find com.android.tools.build:gradle:4.4

I just migrated gradle from 3.0.1 to 4.4.我刚刚将 gradle 从 3.0.1 迁移到 4.4。 Now Android Studio showing gradle build failed showing below errors.现在显示 gradle 构建失败的 Android Studio 显示以下错误。

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:4.4.引起:org.gradle.internal.resolve.ModuleVersionNotFoundException:找不到 com.android.tools.build:gradle:4.4。 Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.jar在以下位置搜索: https : //jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://jcenter.bintray.com/com/android/tools/build /gradle/4.4/gradle-4.4.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://dl.google .com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.jar

Project level build.gradle file is following below项目级 build.gradle 文件如下

 buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:3.0.1'
        //replaced by 4.4 below
        classpath 'com.android.tools.build:gradle:4.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        mavenCentral()
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Project structure is shown below.项目结构如下图所示。

项目结构和gradle设置

You mixed up with plugin version and distributionUrl .你混淆了插件版本和distributionUrl Plugin version should be classpath 'com.android.tools.build:gradle:3.0.1' or com.android.tools.build:gradle:3.1.0 .插件版本应该是classpath 'com.android.tools.build:gradle:3.0.1'com.android.tools.build:gradle:3.1.0 Read Android Plugin for Gradle Release Notes .阅读Android Plugin for Gradle 发行说明

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

And distributionUrl to GradleWrapper .distributionUrlGradleWrapper

distributionUrl = https\://services.gradle.org/distributions/gradle-4.4-all.zip

Currently latest Version 3 gradle plugin available on android for which you have to use classpath 'com.android.tools.build:gradle:3.1.0' .当前最新的版本 3 gradle 插件可在 android 上使用,您必须使用classpath 'com.android.tools.build:gradle:3.1.0'
To be up to date see Configure Your Build .要保持最新状态,请参阅配置您的构建

Guess you mixed up Gradle and Android Gradle Plugin regarding their versions?猜猜你把GradleAndroid Gradle Plugin的版本搞混了?

The latest Android Gradle Plugin is v4.0.0 as of April 2020, which maps to Gradle v6.1.1.截至 2020 年 4 月,最新的 Android Gradle 插件是 v4.0.0,映射到 Gradle v6.1.1。

Please help me to resolve this problem.. 请帮助我解决此问题。

ERROR: Could not find com.android.tools.build:gradle:6.0.1. 错误:找不到com.android.tools.build:gradle:6.0.1。 Searched in the following locations: - https://jcenter.bintray.com/com/android/tools/build/gradle/6.0.1/gradle-6.0.1.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. 在以下位置搜索:-https: //jcenter.bintray.com/com/android/tools/build/gradle/6.0.1/gradle-6.0.1.pom如果要检索的工件可以在以下位置找到在存储库中但没有“ Maven POM”格式的元数据时,您需要调整存储库声明的“ metadataSources {...}”。 Required by: project : Add Google Maven repository and sync project Open File 必填项:项目:添加Google Maven存储库并同步项目打开文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM