当我在Android Studio中“运行”我的项目时,在“消息”窗口中,我得到:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':play01: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.

它说>编译失败;有关详细信息,请参阅编译器错误输出。 那么“编译器错误输出”在哪里呢?我如何运行——stacktrace选项?


当前回答

我是基于乔治的建议。 转到文件- >设置- >编译器。

在这里,您将看到一个用于添加编译器选项的字段——stacktrace

其他回答

设置起来真的很简单!只需进入Android Studio 2.2.3的编译器设置,并设置——stacktrace命令:

然后再次运行应用程序

将android转换为androidx后。

导入库问题将得到解决。 是这样的:

import androidx.appcompat.widget.Toolbar;  <<  like this

进口androidx.annotation.NonNull;<<像这样

进口androidx.appcompat.app.ActionBarDrawerToggle;<<像这样

进口androidx.drawerlayout.widget.DrawerLayout;<<像这样

进口androidx.recyclerview.widget.RecyclerView;<<像这样

进口androidx.appcompat.app.AppCompatActivity;<<像这样

我是基于乔治的建议。 转到文件- >设置- >编译器。

在这里,您将看到一个用于添加编译器选项的字段——stacktrace

这个答案已经过时了。对于Android 3.1 Studio,请访问这个答案

您可以做的一件事是禁用外部构建。要做到这一点,点击“编译器设置图标”在“消息制作”面板出现错误时。你也可以通过文件->设置->编译器打开编译器设置。(感谢@maxgalbu提供这个提示)。

取消勾选“使用外部构建”

你会在控制台中看到错误

编辑:再次返回“内部构建”后,你可能会得到一些错误,你可以这样解决:Android Studio:禁用“外部构建”显示错误输出创建重复的类错误

只需单击Build Output中的“Build”节点

出于某种原因,“编译失败”节点刚刚开始被自动选择,对此,描述窗口是非常没有帮助的。