构建 Android Studio 项目时如何添加 Stacktrace 或调试选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21674091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Add Stacktrace or debug Option when Building Android Studio Project
提问by Neoh
I was trying to investigate the project build error in the console output as follow:
我试图调查控制台输出中的项目构建错误,如下所示:
:myapp:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
...
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I suspect it has something to do with resource not found error. My question is, at IDE level how can I add --stacktrace
or --debug
option so that it can produce more information for me to debug?
我怀疑它与资源未找到错误有关。我的问题是,在 IDE 级别,我如何添加--stacktrace
或--debug
选择以便它可以生成更多信息供我调试?
回答by pyus13
You can use GUI to add these gradle command line flags from
您可以使用 GUI 从以下位置添加这些 gradle 命令行标志
File > Settings > Compiler (Gradle-based Android Project)
For MacOS user, it's here
对于 MacOS 用户,它在这里
Android Studio > Preferences > Build, Execution, Deployment > Compiler
like this (add --stacktrace
or --debug
)
像这样(添加--stacktrace
或--debug
)
(Note that the screenshot is from before 0.8.10, the option is no longerin the Compiler > Gradle
section, it's now in a separate section named Compiler (Gradle-based Android Project)
)
(请注意,截图是 0.8.10 之前的,该选项不再在该Compiler > Gradle
部分中,现在位于名为 的单独部分中Compiler (Gradle-based Android Project)
)
回答by jpa57
On the Mac
version of Android Studio Beta 1.2
, it's under
在 的Mac
版本上Android Studio Beta 1.2
,它在
Android Studio->preferences->Build, Execution, Deployment->Compiler
Android Studio->preferences->Build, Execution, Deployment->Compiler
回答by Angel Koh
回答by Francois
What I use for debugging purposes is running the gradle task with stacktrace directly in terminal. Then you don't affect your normal compiles.
我用于调试目的是直接在终端中使用 stacktrace 运行 gradle 任务。那么你不会影响你的正常编译。
From your project root directory, via terminal you can use:
从您的项目根目录,通过终端您可以使用:
./gradlew assembleMyBuild --stacktrace
回答by user1551978
To add a stacktrace click on the Gradle on the right side of Android project screen;
要添加堆栈跟踪,请单击 Android 项目屏幕右侧的 Gradle;
- Click on the settings icon; this will open the settings page,
- Then click on compiler
Then add the command
--stacktrace
or--debug
as shown;Run the application again to get the gradle report.
- 点击设置图标;这将打开设置页面,
- 然后点击编译器
然后添加命令
--stacktrace
或--debug
如图所示;再次运行应用程序以获取 gradle 报告。
回答by auspicious99
(edited Dec 2018: Android Studio 3.2.1 on Mac too)
(2018 年 12 月编辑:Mac 上也有 Android Studio 3.2.1)
For Android Studio 3.1.3 on a Mac, it was under
对于 Mac 上的 Android Studio 3.1.3,它在
Android Studio -> Preferences -> Build, Execution, Deployment -> Compiler
Android Studio -> Preferences -> Build, Execution, Deployment -> Compiler
and then, to view the stack trace, press this button
然后,要查看堆栈跟踪,请按此按钮
回答by gmetax
For Android Studio 3.1.3 it was under
对于 Android Studio 3.1.3,它位于
File -> Settings -> Build, Execution, Deployment -> Compiler
文件 -> 设置 -> 构建、执行、部署 -> 编译器
回答by Fredy sanchez .m
my solution is this:
我的解决方案是这样的:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
回答by Anthony Cannon
To be able to run options like --stacktrace
within a gradle command, you need to put it at the beginning, like:
为了能够--stacktrace
在 gradle 命令中运行选项,您需要将其放在开头,例如:
./gradlew --stacktrace assembleMyBuild
./gradlew --stacktrace assembleMyBuild