androidandroid-databindingandroid-libraryjitpackandroid-binding-adapter

Android Custom Library Module BindingAdapter Attribute Not Recognized


So I just learned how to publish my own library (just some utility functions) through Github and JitPack, here is my code:

https://github.com/xht418/Util-Kotlin/tree/main/utlikotlin/src/main/java/com/example/utlikotlin

My problem is, the Double.roundDecimal() is recognized, but my custom DataBinding attribute isAddCase is not recognized, shows AAPT: error: attribute isAddCase (aka com.example.shapeableimageviewtest:isAddCase) not found.

I've tried in a new project:

<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <variable
            name="name"
            type="String" />

    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@{name}"
            app:isAddCase="true"/>    //either "isAddCase" or "app:isAddCase", doesn't work

    </LinearLayout>

</layout>

Solution

  • You have to change app:isAddCase=true with app:isAddCase="@{true}"