How does the Android compiler work? Does it remove the comments in Java code and Android XML files on compilation?
Comments in Java files are removed, or ignored, when they are compiled into class files. Class files are not for human-reading - they are optimized to run efficiently on a virtual machine. If the comments were to remain, they would just cause the class files to be larger than required, and for no additional benefit (ie, the compiler and virtual machines don't understand comments, so why include them)
As for XML files, the comments are usually retained. Whereas a compiled class file only has 1 purpose (to run on a virtual machine), an XML file could serve many purposes. For example, you can load an XML file into your application and manipulate it. Depending on the use of the XML file in your application, it might be required to keep the comments in there - in fact, your application might specifically look for comments. Because XML files could have a wide range of uses, the comments aren't removed from XML files in case they are required for some other purpose.