Android出现In MenuView, unable to find attribute android:preserveIconSpacing错误信息

错误信息:

[2017-08-16 20:38:40 - appcompat_v7] ERROR: In <declare-styleable> MenuView, unable to find attributeandroid:preserveIconSpacing
[2017-08-16 20:38:42 - apps] ERROR: In <declare-styleable> MenuView, unable to find attributeandroid:preserveIconSpacing


解决方案:

第一种方法:首先找到appcompat_v7项目包==》res文件夹==》values文件夹==》attrs.xml文件搜索android:preserveIconSpacing

把name="android:preserveIconSpacing"的attr标签注释掉或者删除。


第二种方法:在整个项目中,进行全局搜索(快捷键:Ctrl+H)

选择File Search视图,并在Containing text中输入android:preserveIconSpacing

如下图所示:

Android出现In <declare-styleable> MenuView, unable to find attribute android:preserveIconSpacing错误信息


会出现如下结果图:

Android出现In <declare-styleable> MenuView, unable to find attribute android:preserveIconSpacing错误信息

对上面的结果进行双击进入,然后就可以找到此标签


并对标签进行注释,如下图所示:

Android出现In <declare-styleable> MenuView, unable to find attribute android:preserveIconSpacing错误信息


然后就可以看到项目没有错误了。