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.
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:
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:
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).
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:
Though the syntax is slightly different:
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":
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…