I'm already replacing XML code with Jetpack Compose and I need to load image to Image component in Jetpack Compose. I've used Glide in legacy code so I imported Coil library but its not working in my code. I already cleared cache and rebuilt project but its still not recognizing Coil components.
Gradle:
implementation("io.coil-kt:coil:2.3.0")
Code:
@Composable
fun userAvatar(url: String){
Box(
modifier = Modifier
.size(50.dp)
.padding(4.dp)
) {
AsyncImage(
model = url,
contentDescription = "User Avatar",
modifier = Modifier
.fillMaxSize()
.clip(CircleShape)
)
}
}
Getting
"Unresolved reference: AsyncImage"
.
I found I can use also something like this:
val painter: Painter = rememberCoilPainter(request = url, fadeIn = true)
and then apply it to regular Image but this function also says "Unresolved reference".
You are importing the wrong coil lib version for the compose.
you need to import the coil lib made for Jetpack Compose. Replace it with this