gradle配置文件中将buildToolsVersion等从27升为28之后,sync project一直失败,报错如下。
Android resource compilation failed
Output: D:\AndroidStudio\*\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:828: error: <item> inner element must either be a resource reference or empty.
D:\AndroidStudio\*\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:852: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\lei\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\e4f2f0508854806e66c036005cf75d9c\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
D:\AndroidStudio\*\app\build\intermediates\res\merged\debug \
D:\AndroidStudio\*\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
尝试了删除各种文件并且重启之后,发现这个方法有效,但是android studio提示2018年末终止使用这个,所以还是要看看别的方法。
https://stackoverflow.com/questions/46512990/gradle-error-failed-to-create-directory
I've met this error with Android Studio 3.0RC.
How to solve:
open (ctrl+shift+N): gradle.properties
add line: android.enableAapt2=false
最后从下面这个链接中发现可以是xml文件导致的,于是删去\app\src\main\res\values目录下的ids.xml文件,然后重新sync,project就正常了。
https://stackoverflow.com/questions/52532999/android-hello-world-project-error-daemon-aapt2-aapt2-3-2-0-4818971-windows-da