Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.
Apache License 2.0
592 stars 23 forks source link

Kamel default Android config pulls in desktop loader? #64

Closed 19lmyers closed 8 months ago

19lmyers commented 8 months ago

I have a multiplatform project that I just updated to Kamel 0.8.1 (it was on 0.7.x). On launch of the Android app, which has a KamelIImage on the main screen, it crashes with the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/ProcessHandle;
   at io.kamel.core.cache.HttpCache_desktopKt.dataPath(httpCache.desktop.kt:15)
   at io.kamel.core.cache.HttpCache_desktopKt.<clinit>(httpCache.desktop.kt:29)
   at io.kamel.core.config.KamelConfigBuilder$httpCache$1.invoke(KamelConfigBuilder.kt:70)
   at io.kamel.core.config.KamelConfigBuilder$httpCache$1.invoke(KamelConfigBuilder.kt:69)
   at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:76)
   at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:72)
   at io.ktor.client.plugins.cache.HttpCache$Companion.prepare(HttpCache.kt:121)
   at io.ktor.client.plugins.cache.HttpCache$Companion.prepare(HttpCache.kt:115)
   at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:84)
   at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:81)
   at io.ktor.client.HttpClientConfig.install(HttpClientConfig.kt:104)
   at io.ktor.client.HttpClient.<init>(HttpClient.kt:172)
   at io.ktor.client.HttpClient.<init>(HttpClient.kt:84)
   at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:43)
   at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:21)

(truncated, it was a very long stack trace)

What I don't understand is why my Android app is referencing desktop code. Is there something wrong with my dependencies? Previous versions worked fine.

luca992 commented 8 months ago

@19lmyers I think it's a publishing issue. I managed to reproduce it. I'll get a fix up in 0.8.2 in the next couple days. In the meantime you can downgrade to 0.7.x or disabling the disk cache might work in your KamelConfig like this:

KamelConfig {
    // ... your config
    // use a httpFetcher without the httpCache enabled like this:
    httpFetcher()
}
luca992 commented 8 months ago

0.8.2 was just released with a publishing fix. Should resolve this issue

BassirouRabo commented 8 months ago

Thanks for fixing this issue, i was struggling to figure out what was the issue