简体   繁体   中英

'No resource identifier found for attribute' error even after using namespace http://schemas.android.com/apk/res-auto

Im porting an existing app to gradle build system and got the following error while doing a build from command line error: No resource identifier found for attribute 'ignore_vertical_scroll' in package 'com.example.dummyapp'

Now 'ignore_vertical_scroll' is a custom attribute defined in attrs.xml using it as abc:ignore_vertical_scroll="true" in the layout where xmlns:abc="http://schemas.android.com/apk/res-auto"

What I have read till now is that this URI was added in ADT 17.0 to mitigate package name issues in custom components. Not sure how this translates in gradle.

Found the problem.

I had defined these attributes in the attrs.xml in the following format

<declare-styleable name="HorizontalPager">
      <attr name="ignore_vertical_scroll" format="boolean" />
      <attr name="page_width_proportion" format="integer" />
</declare-styleable>
<declare-styleable name="HorizontalPager">
      <attr name="off_screen_page_limit" format="integer" />
</declare-styleable>

Both the styles had the same name and now during compilation the second attribute definition was overriding the first attribute definition because of which aapt was not able to find the said attributes. Combining these two definitions into a single one fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM