Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Unable to find a fetcher for class io.ktor.http.Url" in iOS only

bcmedeiros opened this issue · comments

We started using Kamel recently and just realized our images are not loading on iOS. Everything works fine on Android, though.

Our code looks like the one below:

            KamelImage(
                resource = asyncPainterResource(player.avatarUrl),
                onLoading = { progress -> CircularProgressIndicator(progress) },
                onFailure = { e ->
                    showDefaultAvatar = true
                    println(e.message.toString())                   // <-- this is printing the error in the title, on iOS only
                },
                contentDescription = "Avatar",
                modifier = modifierAvatar,
            )

We have Ktor engines for all platforms. Is this error message correct?

That's not ktor related. Are you overriding LocalKamelConfig somewhere to not include the defaults?

Hi @luca992, actually this error happened with me. I did not override LocalKamelConfig anywhere. I just included the ktor dependencies for common, android and ios as per documentation and then tried to call KamelImage(data) from the iOS emulator and it does not display the image. However, in the android works fine.

what versions of compose and kotlin are you all using? I added an ios sample and everything is working fine there. Check it out for reference

We are using Kotlin 1.9.10 and compose 1.5.1, but we figure out it was our mistake after all.

All URLs in our app are computed using a BASE_URL variable as a prefix, and in iOS this variable had a ws:// instead of a http://. After fixing this mistake, images started loading on iOS again.

Even though it was our mistake, though, I think the error message is pretty weird, maybe that can be improved. I'll close the ticket, anyway, as I think the error message improvement can be a standalone PR.

Thanks for the prompt help!