我遇到以下错误:"无法使用Gradle分发执行构建' https://services.gradle.org/distributions/gradle-4.4-all.zip'。"
只有在我的gradle文件中有此内容时才会出现: " classpath' com.android.tools.build:gradle:3.1.2'"
如果我将其切换回: " classpath' com.android.tools.build:gradle:3.0.1'"
一切都有效。这是在我今天更新了gradle和android studio之后开始的。
我在这个问题中尝试了几乎所有解决方案,但没有任何帮助: Gradle error: could not execute build using gradle distribution
从上面: - 我尝试删除用户文件夹中的.gradle,然后重新启动android studio(我在其他几次尝试后也重启了我的电脑)
-gradle build成功,我尝试了无效的缓存并重新启动。 (我在删除.gradle之前尝试了这个,它会再做一次吗?)
- 我尝试将gradle设置为其他几条路径,但没有任何帮助。如果我去我的android studio文件夹/ gradle有一个gradle-4.4文件夹,但没有任何以前版本的工作。 .gradle虽然有4.4和4.1。
我尝试了以下gradle home路径:
C:/ Program Files / Android / Android Studio / gradle / gradle-4.4
C:/Users/Joseph/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4
的/ usr /本地的/ opt / gradle这个/的libexec /
和path / to / gradle / libexec /
以及默认包装器。 (我把它设置为现在)
我的jdk / jre可能设置错误,但他们一直在努力工作到现在。
我的项目gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "IdlePortalDefense"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.1'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
google()
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
implementation project(":core")
implementation "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
implementation "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
}
}
project(":core") {
apply plugin: "java"
dependencies {
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
我的graddle包装器:
#Wed Apr 25 00:05:44 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
答案 0 :(得分:0)
感谢FF7Squirrelman分享问题的解决方案。 对我来说,我还通过将gradle分布从gradle-4.4-all.zip更新为gradle-4.7-all.zip
来解决了这个问题。我遇到的问题是我可以“构建APK”并通过Android Studio在手机上运行它。但是,当我生成签名的APK时,出现了与上面相同的错误。
环顾网络,这听起来像是gradle-4.4上的错误会导致该问题,正如F7Squirrelman建议的那样,我下面继续解决该问题:
更新gradle-wrapper.properties: distributionUrl = https://services.gradle.org/distributions/gradle-4.7-all.zip
转到文件->设置->构建,执行和部署->编译器 取消选中该框:按需配置
这将允许在gradle 4.7中构建项目,并最终解决该问题。