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

查看:226
本文介绍了在哪里可以找到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?

推荐答案

注意: ,这不是一个好主意.现在已弃用AAPT,并将在2018年底将其删除.禁用AAPT仅会延迟不建议使用和删除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天全站免登陆