Hi there, I have used coil3(3.0.0-alpha09) in KMP ...
# multiplatform
s
Hi there, I have used coil3(3.0.0-alpha09) in KMP module and coil(2.7.0) in Native Android modules both in single native android project, but when I try to run the project to load KMP module's code is crashing with the following error, KMP module dep
Copy code
coil3 = "3.0.0-alpha06"

coil3-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3" }
coil-compose-core = { module = "io.coil-kt.coil3:coil-compose-core", version.ref = "coil3" }
coil-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "coil3" }
coil-mp = { module = "io.coil-kt.coil3:coil", version.ref = "coil3" }
and Native module dep
Copy code
composeCoil = "2.7.0"

implementation("io.coil-kt:coil-svg:$composeCoil")
implementation("io.coil-kt:coil-compose:$composeCoil")
Error
Copy code
No static method AsyncImage-Vb_qNX0(Ljava/lang/Object;Ljava/lang/String;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;FLandroidx/compose/ui/graphics/ColorFilter;IZLcoil3/compose/EqualityDelegate;Landroidx/compose/runtime/Composer;III)V in class Lcoil3/compose/SingletonAsyncImageKt; or its super classes (declaration of 'coil3.compose.SingletonAsyncImageKt' appears in /data/app/~~1w8_sGCUkYd7MdcvMZJ2vA==/xyz.penpencil.physicswala-5a-6FMY9LuNtojFtuSgDkw==/base.apk!classes22.dex)
	at com.kmmpwui.ui.utils.NetworkImageKt.NetworkImage(NetworkImage.kt:32)
c
Cross posting to multiple channels is considered spamming. Please delete this post again as it is Compose related anyway and this is the KMP channel.
s
deleted from compose
this is KMP related only, by mistakenly I posted on compose
c
It’s actually not KMP related, but fine 😁 Most probably it’s Gradle related and you cannot just use the old library version in Android as from the logs you see that it tries to access
coil3
APIs
s
hoo... we need both versions as they mentioned in official doc
c
Then check your code for the correct imports. Looks like you are mixing both apis.
s
Copy code
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.FilterQuality
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import coil3.ImageLoader
import coil3.PlatformContext
import coil3.compose.AsyncImagePainter.State
import coil3.compose.LocalPlatformContext
import coil3.memory.MemoryCache
import coil3.request.CachePolicy
import coil3.request.ImageRequest
import coil3.request.crossfade
import coil3.size.Precision
import coil3.util.DebugLogger

@Composable
fun NetworkImage(
    modifier: Modifier,
    url: String,
    contentDescription: String?,
    contentScale: ContentScale,
    placeholder: Painter? = null,
    onSuccess: () -> Unit = {},
    onError: (State.Error) -> Unit = {},
    errorPainter: Painter? = null
) {

    val context = LocalPlatformContext.current
    coil3.compose.AsyncImage(
        modifier = modifier,
        model = ImageRequest.Builder(context)
            .diskCacheKey(url.trim())
            .memoryCachePolicy(CachePolicy.ENABLED)
            .memoryCacheKey(url.trim())
            .data(url).precision(Precision.EXACT)
            .build(),
        contentDescription = contentDescription,
        contentScale = contentScale,
        placeholder = placeholder,
        error = errorPainter,
        onError = onError,
        onLoading = {
        },
        onSuccess = {
            onSuccess()
        },
        filterQuality = FilterQuality.Low

    )
}
nope Just used coil3 in kmp module
a
Copy code
coil-bom = { group = "io.coil-kt.coil3", name = "coil-bom", version.ref = "coil-bom" }
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose" }
coil-network-ktor = { group = "io.coil-kt.coil3", name = "coil-network-ktor3" }
Copy code
coil-bom = "3.1.0"
Copy code
implementation(project.dependencies.platform(libs.coil.bom))
implementation(libs.coil.compose)
implementation(libs.coil.network.ktor)
for what reason you need coil 2.7?
s
native modules using the 2.7.0 @Arsildo Murati
@Colin White..