Android - Inner element must either be a resource reference or empty

前端 未结 8 1300
天涯浪人
天涯浪人 2020-11-29 04:00

Error Details

AGPBI: {\"kind\":\"error\",\"text\":\"error: \\u003citem\\u003e inner element must either be a resource reference or empty         


        
相关标签:
8条回答
  • 2020-11-29 04:30

    For me this was actually failing because the new gradle versions. I am pretty sure that some plugins I'm using have incompatibilities with newest gradle. I ended up with success build having the following versions:

    gradle-wrapper.properties file:

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
    

    build.gradle file

     dependencies {
       classpath 'com.android.tools.build:gradle:3.0.1'
     }
    

    EDIT:

    As we want to use 3.2.+ versions now, that isn't a reliable solution.

    What I ended up doing is creating a new ids.xml file, and overriding all the values that have been conflicting.

    ids.xml file example:

    <?xml version="1.0" encoding="utf-8"?>
        <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>
    
    0 讨论(0)
  • 2020-11-29 04:41

    To all others who are still scratching their head to get the solution for this is create ids.xml inside src/main/res/values with contents similar to the following (but make sure to update it with the ids you're seeing errors for):

    <?xml version="1.0" ?>
    <items>
        <item name="animator" type="id"/>
        <item name="date_picker_day" type="id"/>
        <string name="deleted_key"/>
    </items>
    

    Now Android Studio will be giving you an error for explicit values and if those values are coming from some library you are using then you can't make a change in the intermediate file so instead change here and while merging your code Android studio takes care of it.

    0 讨论(0)
提交回复
热议问题