Reputation: 2735
Recently I've upgraded my project to Android Studio 3.2.1, Gradel 4.6, Gradle Plugin 4.6 and tagetSDKVersion 28.
However I'm getting below error in the merged values.xml file -
error: <item> inner element must either be a resource reference or empty.
Lines from the merged values.xml which are causing the issues -
<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>
Exact error log
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
I know for sure that these are not from my values and most of them are from the class com.android.datetimepicker.date.DatePickerDialog
and I'm not getting how to fix this as these are from the library and not from my project.
Upvotes: 3
Views: 8172
Reputation: 113
Create a file called ids.xml under res/values folder of your project and it should have
<?xml version="1.0" encoding="utf-8"?><resources>
<item name="animator" type="id"/>
<item name="date_picker_day" type="id" />
<item name="date_picker_header" type="id" />
<item name="date_picker_month" type="id" />
<item name="date_picker_month_and_day" type="id" />
<item name="date_picker_year" type="id" />
<item name="day_picker_selected_date_layout" type="id" />
<item name="done" type="id" />
<item name="month_text_view" type="id" />
<item name="reference" type="id" /></resources>
Upvotes: 3
Reputation: 3351
As the other answer states you need to make sure there is no inner values to the item elements throwing the exception.
In some cases these can be from external libraries so cannot be modified directly, in this case create a file called ids.xml in the folder res/values.
In here you can override any items causing issues, for me I added the following to get over the issue stated in the question.
<resources>
<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>
Upvotes: 1
Reputation: 451
I just replce the following code
<item type="id" name="checkColor">false</item>
to
<item type="id" name="checkColor"></item>
Upvotes: 3
Reputation: 2735
After lot of search I found that it was one of my library which was causing this issue. The library I was using was not compatible with gradle 3.2.1 and which was causing the issues in compilation.
Upvotes: 2
Reputation: 97
The solution is: Create a file called ids.xml into res/values folder and put this content:
`<?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>`
This solved my problems...
Upvotes: 3