gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:33:07 25 4
gpt4 key购买 nike

我在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**

并且我在gradle存储库中添加了maven {url“ https://jitpack.io”}:
**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
}**

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

最佳答案

请尝试将分发网址用作:

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中即可解决此问题。

关于android - 无法解析com.android.tools.build:gradle:3.0.1;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61359382/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com