格拉德尔原木在哪里?

在 Android Studio 中,应用程序的 Gradle build 会产生以下错误:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.RuntimeException: failure, see logs for details.
cannot generate view binders com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.view.View$InvalidateInfo not found

有人能告诉我在哪里能找到日志吗?

起初,我认为这是一个非常基础的问题,简单的答案会出现在顶部快速搜索,但我没有找到它。

请注意这个问题是 关于那些日志,不是针对这个特定的错误。此错误消息仅用作示例。如果您感到好奇,这个特定的错误是由于在 build.gradle 中没有使用最新版本(23)来编译 SdkVersion 而造成的。

88564 次浏览

Gradle does not redirect its logs in a separate file in Android Studio.

Therefore if you want to view them in a file, you need to build gradle using a command in the terminal and redirect gradle input to a file.

gradlew build > myLogs.txt 2>&1

This command will redirect all standard output and error messages from gradle build to a file called myLogs.txt in the project folder.

gradlew build > myLogs.txt 2> logErrors.txt

This command will redirect all standard output from Gradle logs to the myLogs.txt and all error messages to logErrors.txt

Tested on Windows 10 and works perfectly.

Here is more information about how to redirect standard output from commands to different files.

You can also try running your task like this:

>gradlew --info build

You will get a bunch of useful log information

View -> Tool Windows -> Build.

There is small "ab" button on the left panel.

enter image description here

All gradle logs for current build are there.

enter image description here

EDIT: There is new icon from AndroidStudio 3.3

enter image description here

In the Windows version of Android Studio, there should be a "Show Log in Explorer" link that will reveal the Gradle log:

enter image description here

In Android Studio 4 (at least 4.2.1 now), both the ab button and the Toggle View button (mentioned in another answer) are gone, so Android Studio doesn't show the logs in the Build View anymore, but if a gradle sync fails, there is a button that brings you to view the idea log outside Android Studio (see the right-most button below), entitled "Show Log in Finder" (at least, in MacOS Android Studio). Show Log in Finder