android - 无法使用 Gradle 分发 'http://services.gradle.org/distributions/gradle-1.6-bin.zip' 执行构建

标签 android android-studio build.gradle

如果构建项目,Android Studio 出现错误:

Android Studio 中的错误:

Gradle: Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MyApplication:dexDebug'.
> Running C:\Users\Michael\AppData\Local\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed. See output

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

gradlew compileDebug --stacktrace 命令窗口中的输出是:

The TaskContainer.add() method has been deprecated and is scheduled to be remove
d in Gradle 2.0. Please use the create() method instead.
:MyApplication:prepareDebugDependencies
:MyApplication:compileDebugAidl UP-TO-DATE
:MyApplication:generateDebugBuildConfig UP-TO-DATE
:MyApplication:mergeDebugAssets UP-TO-DATE
:MyApplication:compileDebugRenderscript UP-TO-DATE
:MyApplication:mergeDebugResources UP-TO-DATE
:MyApplication:processDebugManifest UP-TO-DATE
:MyApplication:processDebugResources UP-TO-DATE
:MyApplication:compileDebug UP-TO-DATE

BUILD SUCCESSFUL

Total time: 27.437 secs

命令 gradlew clean build 的输出是:

The TaskContainer.add() method has been deprecated and is scheduled to be remove
d in Gradle 2.0. Please use the create() method instead.
:MyApplication:clean
:MyApplication:prepareDebugDependencies
:MyApplication:compileDebugAidl
:MyApplication:generateDebugBuildConfig
:MyApplication:mergeDebugAssets
:MyApplication:compileDebugRenderscript
:MyApplication:mergeDebugResources
:MyApplication:processDebugManifest
:MyApplication:processDebugResources
:MyApplication:compileDebug
:MyApplication:dexDebug
Der Befehl "C:\Program" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
:MyApplication:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MyApplication:dexDebug'.
> Running C:\Users\Michael\AppData\Local\Android\android-studio\sdk\build-tools\
android-4.2.2\dx.bat failed. See output

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 33.459 secs

C:\Users\Michael\AndroidStudioProjects\MyApplicationProject>

有什么想法吗?

最佳答案

我遇到了同样的问题。问题出在 C:\Program Files[...] 中 java 可执行文件路径中的空格。

我解决了在文件 [...]android-studio\sdk\build-tools\android-4.2.2\dx.bat 末尾做一点修改; 如果您已经正确设置 JAVA_HOME 和 JDK_HOME,请替换最后一行:

call  %java_exe% %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %params%

用这一行:

call  java %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %params%

关于android - 无法使用 Gradle 分发 'http://services.gradle.org/distributions/gradle-1.6-bin.zip' 执行构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17031860/

相关文章:

gradle - 在自定义 gradle 插件中处理每个构建类型/ flavor 配置

java - 在评估阶段使用 Gradle 插件配置属性

android -> 任务 :app:checkDebugAarMetadata FAILED when run react-native run-android

android - 将通知服务保留在后台,如 stackoverflow 应用程序

java - 在 android 上播放本地 m3u8 文件显示 setDataSourceFD 失败。 : status=0x80000000

android - 在android studio中删除一个依赖项的未使用文件

android - 需要抽屉导航的帮助

android - 为什么一个 Android Studio 项目中有两个 build.gradle 文件?

java - Android 存储数据的策略

android - 在 OpenGL 中同时使用多个渲染器