AS 出现: inner element must either be a resource reference or empty

有一个老的项目出现如上所示的问题,导致build失败。查看错误问题之后发现代码是如下格式的:

<item name="animator" type="id">false</item>
<item name="date_picker_day" type="id">false</item>

然后网上找到了一些资料:

在开发文档中,https://developer.android.com/guide/topics/resources/more-resources#Id
也有提到说上面那种方式已经不能这么写了,新的方法如下:

<item name="animator" type="id"/>
<item name="date_picker_day" type="id"/>

如果引入的是第三方包怎么修改呢?

1、在你的项目res\values文件夹下新建ids.xml文件

2、将之前编译出错的item重新写一遍,改成下面的

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="animator" type="id"/>
    <item name="date_picker_day" type="id"/>
   ...
</resources>

重新build之后AS会自动处理这些问题。



原作者:有没有一种幸运和你相遇
转自链接:https://www.jianshu.com/p/592308a335ff

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章