最近我将我的项目升级到 Android Studio 3.2.1、Gradel 4.6、Gradle Plugin 4.6 和 tagetSDKVersion 28。
但是我在合并的 values.xml 文件中遇到以下错误 -
error: <item> inner element must either be a resource reference or empty.
导致问题的合并 values.xml 中的行 -
<item name="date_picker_day" type="id">false</item>
<item name="date_picker_header" type="id">false</item>
<item name="date_picker_month" type="id">false</item>
<item name="date_picker_month_and_day" type="id">false</item>
<item name="date_picker_year" type="id">false</item>
<item name="day_picker_selected_date_layout" type="id">false</item>
<item name="done" type="id">false</item>
<item name="month_text_view" type="id">false</item>
<item name="animator" type="id">false</item>
准确的错误日志
Android resource compilation failed
Output: C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6866: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6881: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6882: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6883: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6884: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6885: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6886: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6887: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:6896: error: <item> inner element must either be a resource reference or empty.
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml:7419: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res/android'.
Command: C:\Users\1258503\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\074ce88e9379d4536b62c1cf1690927a\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\res\merged\stage\debug \
C:\AmrutData\Workspace\Q4\Mobile-Quitters-Circle-Android\app\build\intermediates\incremental\mergeStageDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
我确定这些不是来 self 的值(value)观,其中大部分来自 com.android.datetimepicker.date.DatePickerDialog
类,我不知道如何解决这些问题来自图书馆而不是我的项目。
解决方法是:在 res/values 文件夹中创建一个名为 ids.xml 的文件并将此内容放入:
`<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="sos_key_shift_state" type="id"/>
<item name="cc_card" type="id" />
<item name="cc_ccv" type="id" />
<item name="cc_entry" type="id" />
<item name="cc_entry_internal" type="id" />
<item name="cc_exp" type="id" />
<item name="cc_form_layout" type="id" />
<item name="cc_four_digits" type="id" />
<item name="cc_zip" type="id" />
<item name="text_helper" type="id" />
</resources>`
这解决了我的问题...
我是一名优秀的程序员,十分优秀!