Android Studio和Gradle构建错误

Rog*_*ueX 66 android gradle android-studio android-gradle-plugin

我一直在使用android studio的新预览,非常喜欢它.但最近我的项目不会建立.我收到以下错误:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':TestProj:compileDebug'.
> Compilation failed; see the compiler error output for details.

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

Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Run Code Online (Sandbox Code Playgroud)

问题是如何启用堆栈跟踪,以便我可以找到错误的根源.因为它是我真的不知道是什么导致了这一点.

joe*_*ble 45

如果您使用的是Gradle Wrapper(Android Studio中推荐的选项),则可以通过gradlew compileDebug --stacktrace从项目的根文件夹(gradlew文件所在位置)中的命令行运行来启用堆栈跟踪.

如果您没有使用gradle包装器,则可以使用gradle compileDebug --stacktrace(推测).

你真的不需要运行,--stacktrace但是,从命令行单独运行gradlew compileDebug,应该告诉你错误在哪里.

我根据此评论提供此信息:

Android Studio新项目无法运行,抛出错误


小智 7

与@joe_deniable的答案类似,我在自己的项目中发现的事情是,当我的系统配置错误时,gradle会输出这种错误.

我发现通过从终端运行gradlew installDebug或类似的命令,我得到了更好的输出,以确定真正的问题是什么.

例如,最初我发现我的JAVA_HOME设置不正确.然后我发现它遇到了错误,因为我没有正确设置包空间.等等.