【问题标题】:'No resource identifier found for attribute' error even after using namespace http://schemas.android.com/apk/res-auto即使在使用命名空间 http://schemas.android.com/apk/res-auto 后,“没有找到属性的资源标识符”错误
【发布时间】:2013-06-13 09:37:10
【问题描述】:

将现有应用程序移植到 gradle 构建系统并从 命令行 进行构建时出现以下错误 error: No resource identifier found for attribute 'ignore_vertical_scroll' in package 'com.example.dummyapp'

现在'ignore_vertical_scroll' 是在attrs.xml 中定义的自定义属性,在xmlns:abc="http://schemas.android.com/apk/res-auto" 的布局中将其用作abc:ignore_vertical_scroll="true"

到目前为止,我读到的是 ADT 17.0 中添加了此 URI,以缓解自定义组件中的包名称问题。不知道这在 gradle 中是如何翻译的。

【问题讨论】:

    标签: android gradle android-studio build.gradle


    【解决方案1】:

    找到问题了。

    我在 attrs.xml 中定义了这些属性,格式如下

    <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>
    

    两种样式具有相同的名称,现在在编译期间,第二个属性定义覆盖了第一个属性定义,因此 aapt 无法找到所述属性。将这两个定义合并为一个即可解决问题。

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2017-09-28
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多