Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'

There is a error in the Android Studio if the project is built:

The error in the 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.

The output in the command window for gradlew compileDebug --stacktrace is:

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

The output for the command gradlew clean build is:

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>

Anyone an idea?

like image 857
Mokkapps Avatar asked Jun 10 '13 20:06

Mokkapps


People also ask

Why does gradle Sync Fail?

In some cases when your Gradle files are deleted or corrupted you will not be able to download new Gradle files in android studio. In this case, we have to delete the Gradle files which are present already and then again sync your project to download our Gradle files again.

What is a gradle in Java?

Gradle is a build automation tool for multi-language software development. It controls the development process in the tasks of compilation and packaging to testing, deployment, and publishing. Supported languages include Java (as well as Kotlin, Groovy, Scala), C/C++, and JavaScript.

Where are gradle wrapper properties?

The content of gradle-wrapper properties file is as follows: distributionBase=GRADLE_USER_HOME. distributionPath=wrapper/dists. distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip.


Video Answer


2 Answers

I had the very same problem. The problem came from the space in the path for the java executable in C:\Program Files[...].

I solved making a little modification at the end of the file [...]android-studio\sdk\build-tools\android-4.2.2\dx.bat; provided you already set JAVA_HOME and JDK_HOME correctly, substitute the last line:

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

with this line:

call  java %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %params%
like image 182
Miguel El Merendero Avatar answered Oct 29 '22 12:10

Miguel El Merendero


I don't speak German but I know that error - you have a space in your path that's not escaped on Windows (C:\Program Files).

I've no idea where the space is or why you're triggering it (I've successfully used continuous integration on Windows to build Android Gradle projects and it worked just fine). Post your build.gradle, please.

Also, there's a quick and easy test - move everything to a path without spaces and try again.

like image 20
Delyan Avatar answered Oct 29 '22 12:10

Delyan