在哪里可以找到 aapt2 日志? [英] Where to find aapt2 logs?

查看:43
本文介绍了在哪里可以找到 aapt2 日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试构建我的项目时,出现以下错误:

When I try to build my project, I get the following error:

最后声明:检查日志以获取详细信息".在哪里可以找到那些 aapt2 日志?

In the end it is stated: "check logs for details". Where to find those aapt2 logs?

推荐答案

注意: 关于禁用 AAPT2,这不是一个好主意.AAPT 现在已被弃用,并将在 2018 年底被移除.禁用它只会延迟当 AAPT 被弃用和移除时您必须解决的问题.

NOTE: regarding disabling AAPT2, it's not a good idea. AAPT is now deprecated and will be removed by the end of 2018. Disabling it just delays the problems you'll have to fix either way when AAPT is deprecated and removed.

不幸的是,日志不会直接显示在常规构建窗口中.我不知道为什么,或者谁认为这是一个好主意,但这就是它目前的工作方式.您需要弹出基于文本的版本.

The logs do unfortunately not show up directly in the regular build window. I'm not sure why, or who thought it was a good idea, but that's how it currently works. You'll need to pop into the text-based version.

使用 AS 3.1(也可能是 3.0,我使用的是 3.1,所以我无法在那里进行测试)或 IntelliJ 2018.1,您打开构建选项卡:

Using AS 3.1 (possibly 3.0 as well, I'm using 3.1 so I can't test there) or IntelliJ 2018.1, you open the build tab:

在这种情况下,我故意在一些 XML 代码中创建了一个语法错误(还有其他地方你也可以得到 AAPT2 错误,比如在清单或 Kotlin 或其他地方.这只是为了演示).我在图像中突出显示了一个按钮.如果您将鼠标悬停在按钮上,它应该会显示切换视图".单击它,您将进入构建选项卡的基于文本的版本:

In this case I intentionally created a syntax error in some XML code (there are other places you can get AAPT2 errors too, like in the manifest or Kotlin, or somewhere else. This is just for the sake of demonstrating). I've highlighted a button in the image. If you hover over the button it should say "Switch view". Click it and you'll enter the text-based version of the build tab:

在本例中,我将 XML 属性设置为不存在的值.实际问题格式化为JSON(见红圈内容).粉红色的内部是实际的错误消息(未找到资源),蓝色圆圈包含文件(在本例中为 label_layout.xml),黑色圆圈的内容包含位置(第 4 行).

In this case I set an XML property to a non-existent value. The actual problem is formatted as JSON (see the content of the red circle). Inside the pink one is the actual error message (resource not found), the blue circle contains the file (in this case label_layout.xml) and content of the black circle contains the location (line 4).

实际的错误是什么会不时变化,所以我不打算添加如何解决它,因为有很多不同的问题可能是原因.大多数时候是你的代码(到目前为止,我还没有看到任何 AAPT2 崩溃或存在阻止编译的错误的情况).通过体面的日志输出,实际解决这些问题会容易得多.

What the actual error is will vary from time to time, so I'm not going to add how to solve it, because there's a wide range of different problems that could be the cause. Most of the time it's your code (so far I haven't seen any cases where AAPT2 crashes or has a bug that prevents compiling). Actually solving these issues get a lot easier with decent log output.

作为参考,同样适用于编译错误:

For reference, the same applies to compilation errors:

虽然语法略有不同:

图标在以后的版本中发生了变化.除此之外,我不会保持图标本身的主动更新.

The icon changed in a later version. I will not be keeping active updates of the icon itself beyond this.

供将来参考:将鼠标悬停在构建窗口中的按钮上,直到找到显示切换视图"的按钮:

For future reference: hover over the buttons in the build window until you find one that says "Toggle view":

这就是您正在寻找的按钮,无论 Google 决定在未来版本的 Android Studio 中使用什么图标 - 至少在他们解决问题之前是这样.

That is the button you're looking for, regardless of what icon Google decides to use for it in future versions of Android Studio - at least until they fix the issues.

这篇关于在哪里可以找到 aapt2 日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆