Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

338
Vistas
@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 Respuestas
Responde la pregunta

0

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

TL;DR:

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

0

@BindingAdapter("imageUrl") 

instead of

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda