Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
@BindingAdapter not working with Android Kotlin library

I've this BindingAdapter to load image using Glide in my library module

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide

@BindingAdapter("imageUrl")
fun loadImage(view: ImageView, imageUrl: String) {
    Glide.with(view)
        .load(imageUrl)
        .into(view)
}

and I tried to use the adapter like this

   <ImageView
            ...
            app:imageUrl="@{`http://pngimg.com/uploads/alfa_romeo/alfa_romeo_PNG75.png`}"
            ... />

but am getting

****/ data binding error ****msg:Cannot find the setter for attribute 'app:imageUrl' with parameter type java.lang.String on android.widget.ImageView.

The weird thing is, when I convert the BindingAdapter to Java from Kotlin, it works.

public class ImageViewBindingAdapter {

    @BindingAdapter("imageUrl")
    public static void setImageUrl(ImageView view, String url) {
        Glide.with(view)
                .load(url)
                .into(view);
    }
}

NOTE: This issue only exist with the library module. App module works perfectly fine with the Kotlin file.

What am I doing wrong ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Duplicated: https://stackoverflow.com/a/52668004/1607169

TL;DR:

apply plugin: 'kotlin-kapt'
over 4 years ago · Santiago Trujillo Report

0

@BindingAdapter("imageUrl") 

instead of

@BindingAdapter("app:imageUrl")
over 4 years ago · Santiago Trujillo Report

0

your code should be like this

object BindUtil {
  @JvmStatic
  @BindingAdapter("app:imageUrl")
  fun imageUrl(view: ImageView, imageUrl: String?) {
      Glide.with(view)
       .load(imageUrl)
       .into(view)
  }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!