I am trying to load the images of different user using the image link shared by the api, but neither the “rememberAsyncImagePainter” loading the given image nor it is loading the default image, which I had provided.
It is giving this error when I did the debug :
2024-12-27 10:28:49.265 12240-12240 ImagePainterError com.example.messagesendingapp D Failed to load image (Ask Gemini)
java.lang.IllegalStateException: Unable to create a fetcher that supports: https://img.freepik.com/free-vector/smiling-young-man-illustration_1308-174669.jpg
at coil3.intercept.EngineInterceptor.fetch(EngineInterceptor.kt:153)
at coil3.intercept.EngineInterceptor.execute(EngineInterceptor.kt:115)
at coil3.intercept.EngineInterceptor.access$execute(EngineInterceptor.kt:32)
at coil3.intercept.EngineInterceptor$intercept$2.invokeSuspend(EngineInterceptor.kt:66)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
2
Even though when I copied the url and paste to browser, it is working fine. I humbly request you to help me to solve this issue.
@Composable
fun NewConversationsScreen(state: NewConversationState,modifier: Modifier = Modifier){
when{
state.isLoading -> {
CircularProgressIndicator()
}
state.error != null -> {
Text(text = state.error)
}
else -> {
LazyColumn(
modifier = modifier.fillMaxSize()
) {
Log.d("NewConvScreen","Users are : ${state.users.users}")
items(state.users.users){user->
val painter = rememberAsyncImagePainter(
model = user.photo ?: "https://plus.unsplash.com/premium_photo-1683865776032-07bf70b0add1?q=80&w=1932&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
)
Row (
modifier = Modifier.padding(16.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
){
//Profile Photo
Box(
modifier = Modifier
.size(40.dp)
.clip(RoundedCornerShape(32.dp))
.border(1.dp, Color.Black, RoundedCornerShape(32.dp))
){
androidx.compose.foundation.Image(
painter = painter,
contentDescription = "Profile Photo",
modifier = Modifier.fillMaxSize()
)
}
Spacer(modifier = Modifier.width(16.dp))
Text(text = user.name ?: "No Name")
}
}
}
}
}
}
coil compose version is -> 3.0.4