I have a function refreshPictureOfDay() in my view model which calls a retrofit service query to retrive the PictureOfDay object
private val _pictureOfDay = MutableLiveData<PictureOfDay>()
val pictureOfDay: LiveData<PictureOfDay>
get() = _pictureOfDay
init {
viewModelScope.launch {
refreshPictureOfDay()
}
}
private suspend fun refreshPictureOfDay() {
withContext(Dispatchers.IO) {
try {
_pictureOfDay.postValue(
NasaApi.retrofitService.getPictureOfTheDay()
)
} catch (err: Exception) {
Log.e("refreshPictureOfDay", err.printStackTrace().toString())
}
}
}
Then i have a binding adapter
@BindingAdapter("imageUrl")
fun bindImage(imageView: ImageView, url: String?) {
Picasso.with(imageView.context)
.load(url)
.placeholder(R.drawable.placeholder_picture_of_day)
.error(R.drawable.placeholder_picture_of_day)
.into(imageView)
}
Using this binding adapter i try to set the image in my XMl file
app:imageUrl="@{viewModel.pictureOfDay.url}"
I don't know why but it is not working and it logs the following error

This is the PictureOfDay class
data class PictureOfDay(@Json(name = "media_type") val mediaType: String, val title: String,
val url: String)
I am still a beginner so any help would be apprciated