代码之家  ›  专栏  ›  技术社区  ›  Malwinder Singh

错误:<value>与attribute<package>:<attribute\u name>(attr)reference[weak]不兼容

  •  0
  • Malwinder Singh  · 技术社区  · 7 年前

    我正在尝试整合 this 图书馆。我有一个“缺少属性”的问题,所以我将这些属性添加到我的项目中:

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <declare-styleable name="app">
            <attr name="isDone" format="boolean"/>
            <attr name="isVisible" format="boolean"/>
        </declare-styleable>
    </resources>
    

    之后,当我清理项目并再次运行构建过程时,我得到了这个问题:

    error: '@{viewModel.hasStartDate}' is incompatible with attribute com.example:isVisible (attr) reference [weak].
    Message{kind=ERROR, text=error: '@{viewModel.hasStartDate}' is incompatible with attribute com.example:isVisible (attr) reference [weak]., sources=[/home/local/<USER_NAME>/.gradle/caches/transforms-1/files-1.1/DateTimeRangePicker-v1.3.aar/524561517fca999eba7db795be3a768d/res/layout/date_time_range_picker.xml:52], original message=, tool name=Optional.of(AAPT)}
    

    在某些地方,其中之一是由使用数据绑定的库生成的布局文件中的此行:

        app:isDone="@{viewModel.isCompletable}"
    

    在该库生成的Kotlin代码中,声明为:

      val isCompletable = ObservableBoolean()
    

    这个图书馆在科特林。 是什么引起的?

    是卡普特吗? 它是数据绑定吗?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Malwinder Singh    7 年前

    声明的属性必须属于 string 类型

        <attr name="isDone" format="string"/>
        <attr name="isVisible" format="string"/>