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

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