6

如果项目构建,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>

任何人的想法?

4

2 回答 2

3

我有同样的问题。问题来自 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%
于 2013-07-02T11:09:17.147 回答
1

我不会说德语,但我知道这个错误 - 您的路径中有一个空格,在 Windows 上没有转义(C:\Program Files)。

我不知道空间在哪里,也不知道为什么要触发它(我已经成功地在 Windows 上使用持续集成来构建 Android Gradle 项目,并且效果很好)。请张贴你的build.gradle

此外,还有一个快速简单的测试 - 将所有内容移动到没有空格的路径并重试。

于 2013-06-17T23:03:50.963 回答