我正在 Android Studio 上开发一个应用程序,一切都很顺利,但是当我将 android studio 更新到最新的 3.2.1 时。每当我重建它时,它就会开始抛出如下错误:
'Cannot resolve symbol r'
Android resource compilation failed
Output: C:\Users\User\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2387: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\User\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\95f7c8f43460b8291b9636dd6edf99d6\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\User\AndroidStudioProjects\MyApplication\app\build\intermediates\res\merged\debug \
C:\Users\User\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
值.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2" xmlns:ns2="http://schemas.android.com/tools">
values.xml
这一行出现错误:
<item name="textviewprofile" type="id">Logout</item>
我尝试了所有可能的方法来修复 values.xml
中的错误,但没有解决方案,每当我对 values.xml 文件进行更改时,默认文件会在重建后再次出现。任何帮助将不胜感激
非常感谢您在这件事上的时间和帮助。
最佳答案
对于 id 类型的项目,不需要任何值。只需删除该值。用这个
<item name="textviewprofile" type="id"/>
代替
<item name="textviewprofile" type="id">Logout</item>
关于更新到 3.2.1 后 Android 资源编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52988103/