Android resource compilation failed in v3.2-ThrowExceptions

Exception or error:

So I updated my Android Studio to v3.2. When I tried compiling the project, build fails.
Below is the error:

Android resource compilation failed
    Output:  C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:900: error: <item> inner element must either be a resource reference or empty.

    Command: C:\Users\Ashish\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\7f1fbe9171e916e5044000cd76b749c8\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
            -o \
            C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\res\merged\debug \
            C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
    Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

Please do tell if there is any more information required. Any help will be appreciated.

How to solve:

I was facing this issue today after updating gradle from 3.1.4 to 3.2.0. I don’t know why, but the build started to throw that exception. i deleted the build folder, and deleted the gradle caches folder but nothing worked, so i looked at the merged values.xml and turns out that my ids.xml was defining a wrong id that was being merged to the values.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="downloading_package" type="id">Baixando pacote de sincronizaĆ§Ć£o</item>
</resources>

And apparently this was working before the update… for my case i deleted the ids.xml file (it was useless in the project)

I wish i could know why before the update everything was working

###

the <item> in values.xml at line 900 …might be of resource-type id.

the correct syntax would be (just as the error message tells):

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

see the documentation.

###

I’m just finishing this issue a few minutes ago, try to modify or delete id.xml, if you think you don’t have it, try to find in another module in your app. I change my value resource from <item name="header_view" type="id">header_view</item> to <item name="header_view" type="id"/> and it worked for me.

###

i also meet the problem,you just need to find where the values in,and update it from <item type="id" name="id_name" >id_name</item> to <item type="id" name="id_name" />,now it’s ok.

###

For me I had the layout width and layout height in the layout view and the LinearLayout view for databinding. and this threw a duplicate error. I fixed this by removing the set of attributes in the ”.
layout file used for databinding

###

in your build gradle(Project:name) do it like that

classpath 'com.android.tools.build:gradle:3.+'

then rebuild your project .. after that it will show message to update your gradle from 4.6 to 4.10

###

In my case

<?xml version="1.0" encoding="utf-8"?>

is repeated twice in the XML. Make sure it should be one per a file at the top of the XML.

###

This is what worked for me:

In my build.gradle file > dependencies, I was implementing a newer version of appcompat library

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:support-v4:21.0.3'
   implementation 'com.android.support:appcompat-v7:21.0.3'
   implementation 'androidx.appcompat:appcompat:1.0.2'}

After commenting //implementation 'androidx.appcompat:appcompat:1.0.2' It worked fine. I would suggest, even if it’s a different library, Please check the version you are using.

###

In your xml file, you may forget to add /> to brace your attribute.

Leave a Reply

Your email address will not be published. Required fields are marked *