Search code examples
kotlinandroid-jetpack-composecompose-multiplatformkmp

In compose multiplatform, ios throws error on load image


I am using compose multiplatform I'm currently working on a project using Compose Multiplatform project, and looking for ways to handle image loading from a URL. While sync I get error

Error: :composeApp:iosArm64Main: Could not find io.coil-kt.coil3:coil-network-ktor:3.0.0-rc01. Required by: project :composeApp

toml version file

[version]
kotlin = "2.0.20"
coil = "3.0.0-rc01"
ktor = "3.0.0"

[libraries]
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" }
coil-compose-core = { module = "io.coil-kt.coil3:coil-compose-core", version.ref = "coil" }
coil-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "coil" }
coil-mp = { module = "io.coil-kt.coil3:coil", version.ref = "coil" }

here is my gradle

sourceSets {
        
        androidMain.dependencies {
            implementation(compose.preview)
            implementation(libs.androidx.activity.compose)

            //coil
            implementation(libs.ktor.client.okhttp)


        }

        iosMain.dependencies {

            //coil
            implementation(libs.ktor.client.darwin)
        }

        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodel)
            implementation(libs.androidx.lifecycle.runtime.compose)

            //coil
            implementation(libs.ktor.core)
            implementation(libs.coil.compose.core)
            implementation(libs.coil.mp)
            implementation(libs.coil.network.ktor)
            implementation(libs.coil.compose)
        }
    }

Can any one tell me what is wring here.


Solution

  • It's because of the version numbers on Maven. The other libraries you are importing are at 3.0.0-rc01, but the most recent version available for io.coil-kt.coil3:coil-network-ktor is 3.0.0-alpha08. If you update your toml with

    [version]
    ...
    coil-network = "3.0.0-alpha08"
    

    and change your coil-network-ktor library to

    coil-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "coil-network" }
    

    it should fix the issue.