一、前言:
公司項目中之前用的是Eclipse 項目轉化為 Android Studio 項目時報錯“<item> inner element must either be a resource reference or empty”
有的人更新AS之后,之前有一個老的項目出現(xiàn)如上所示的問題,導致build失敗。
翻譯之后: <item>內部元素必須是資源引用或為空。
二、解決:
1. 錯誤格式:
<item name="animator" type="id">false</item>
<item name="date_picker_day" type="id">false</item>
在開發(fā)文檔中,https://developer.android.com/guide/topics/resources/more-resources#Id
也有提到說上面那種方式已經不能這么寫了,新的方法如下:
2. 正確格式:
<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會自動處理這些問題。
參考作者:有沒有一種幸運和你相遇
鏈接:http://www.itdecent.cn/p/592308a335ff