Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

后端 未结 30 1487
野的像风
野的像风 2020-11-22 12:51

This is the output of my Gradle console, I am unable to build my project

D:\\Android Projects\\....\\app\\src\\main\\res\\layout\\topic_view_header.xml
Error         


        
30条回答
  •  渐次进展
    2020-11-22 13:57

    I had exactly the same issue: After updating to Android Studio 3.1.2 my project wouldn't compile with an AAPT2 error telling me some of my drawables which are referenced by styles.xml could not be found. Disabling AAPT2 isn't a solution anymore, since the setting is deprecated and will be removed at the end of 2018.

    Culprit was an empty line just before the xml decleration in a totally unrelated layout.xml file... So the layout.xml file started like this:

    //empty line//
    
    

    Removed the empty line and everything worked like a charm again. Unbelievable and unlikely, but true.

    Android Studio actually gave a warning because the file didn't start with the xml decleration (because of the empty line). But the warning is only visible when the file is opened in the editor.

提交回复
热议问题