繁体   English   中英

无法解析 com.android.tools.build:gradle:3.0.1;

[英]Could not resolve com.android.tools.build:gradle:3.0.1 ;

我在 gradle-properties 中使用它:

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

build.gradle:

**buildscript {
        repositories {
            google()
            mavenCentral()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
            classpath 'com.google.gms:google-services:3.0.0'
            // NOTE: Do not place your application dependencies here; they 
             //belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            jcenter()
             maven {
                url 'https://maven.google.com'
            }
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }**

我有这个错误:

**failed org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':classpath'.
    org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:3.0.1.
    org.gradle.api.resources.ResourceException: Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
    org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0`enter code here`.1.pom'.
    org.apache.http.conn.HttpHostConnectException: Connect to dl.google.com:443 [dl.google.com/172.217.160.238] failed: Connection timed out: connect
    java.net.ConnectException: Connection timed out: connect**

我已经用 gradle 5.6.4 更新了 gradle.properties:

**distributionBase=GRADLE_USER_HOME
            distributionPath=wrapper/dists
            zipStoreBase=GRADLE_USER_HOME
            zipStorePath=wrapper/dists
            distributionUrl=https\://services.gradle.org/distributions/gradle- 
    5.6.4-all.zip**

And I have added maven { url " https://jitpack.io " } in gradle repositories:

**buildscript {
        repositories {
            google()
            mavenCentral()
            jcenter()
            maven { url "https://jitpack.io" }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.6.1'
            classpath 'com.google.gms:google-services:3.0.0'
            // NOTE: Do not place your application dependencies here; 
           //they belong
            // in the individual module build.gradle files
        }
    }
    allprojects{
        repositories {
            jcenter()
            maven {
                url 'https://maven.google.com'
            }
            maven { url "https://jitpack.io" }
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }**

我已经设置了代理并设置了它,但问题仍然存在。

请尝试使用分布 url 作为:

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

并在 build.gradle:project:

   buildscript {
        repositories {
            google()
            mavenCentral()
            jcenter()
            maven { url "https://jitpack.io" } // add this line.

        }
        dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
            classpath 'com.google.gms:google-services:3.0.0'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            jcenter()
             maven {
                url 'https://maven.google.com'
            }
            maven { url "https://jitpack.io" } // add this line.

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

您需要添加maven { url "https://jitpack.io" } // add this line. 在项目 build.gragle 中为了解决这个问题。

暂无
暂无

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

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