Hi Guys, a Few hours ago I was able to run both A...
# multiplatform
a
Hi Guys, a Few hours ago I was able to run both Android and iOS until now I have been facing this error. Anyone has any clue what it means?
Copy code
Task :shared:compileKotlinIosArm64 FAILED
e: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/anshulupadhyay/Desktop/Android_projects/kmmMovieBuffGit/KmmMovieBuff, /Users/anshulupadhyay/.konan/klib, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/common, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/platform/ios_arm64]

> Task :shared:metadataCommonMainClasses
> Task :shared:allMetadataJar

> Task :shared:compileKotlinIosSimulatorArm64 FAILED
e: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/anshulupadhyay/Desktop/Android_projects/kmmMovieBuffGit/KmmMovieBuff, /Users/anshulupadhyay/.konan/klib, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/common, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/platform/ios_simulator_arm64]

> Task :shared:verifyReleaseResources

> Task :shared:compileKotlinIosX64 FAILED
e: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/anshulupadhyay/Desktop/Android_projects/kmmMovieBuffGit/KmmMovieBuff, /Users/anshulupadhyay/.konan/klib, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/common, /Users/anshulupadhyay/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.21/klib/platform/ios_x64]
m
Your cache got corrupted somehow. Try removing derivedData (Xcode Cache. You get there from Xcode > Preferences > Locations > Derived Data) and the gradle cache. Create a new project with iOS support using the KMP wizard and do the gradle sync so the files get downloaded again.
a
@McEna I did exactly what you suggested but no luck again the same error.
😪 1
m
Can you build a fresh project?
a
@McEna yes, the fresh project works fine for both android and iOS. But in my existing kmm project Android app builds and runs perfectly fine but when I build the project it throws the above-mentioned error.
m
If a fresh project works, and you have the same dependencies, plugins & kotlin versions, refresh it by running ./gradlew clean --refresh-dependencies && gradlew build --rerun-tasks
a
@McEna nothing is working. I might have to reconfigure the iOS project or something else. But right now I am clueless.
m
What is your project's layout? Is shared a common library module imported by a kmm app?
a
Copy code
plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.jetbrainsCompose)
    kotlin("native.cocoapods")
    kotlin("plugin.serialization") version "1.9.22"
    id("kotlin-parcelize")
    //id("com.codingfeline.buildkonfig") version "+"
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "17"
            }
        }
    }

   /* @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        moduleName = "moviebuffapp"
        browser {
            commonWebpackConfig {
                outputFileName = "moviebuff.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    open = mapOf(
                        "app" to mapOf(
                            "name" to "google chrome dev"
                        )
                    )
                }
            }
        }
        binaries.executable()
    }*/

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "moviebuff"
            isStatic = true
        }
    }

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic=true
            export(libs.arkivanov.decompose)
            transitiveExport = true
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(compose.runtime)
                implementation(compose.foundation)
                implementation(compose.material3)
                implementation(compose.ui)
                @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
                implementation(compose.components.resources)
                implementation ("io.github.oleksandrbalan:textflow:1.1.0")


                implementation(libs.kotlinx.coroutines.core)

                //Image downloading
                implementation(libs.coil.coil)
                implementation(libs.coil.compose)
                implementation(libs.coil.network.ktor)

                // Ktor
                implementation(libs.ktor.client.core)
                implementation(libs.ktor.client.content.negotiation)
                implementation(libs.ktor.client.serialization.json)
                implementation(libs.ktor.client.logging)

                //di,navigation,lifecycle
                api(libs.arkivanov.decompose)
                implementation(libs.arkivanov.jetbrains.uiext)

                //kotlin date&time
                implementation(libs.kotlinx.datetime)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
         androidMain.dependencies{
             implementation(libs.kotlinx.coroutines.android)

             // Android
             implementation(libs.androidx.activity.compose)
             implementation(libs.androidx.appcompat)
             implementation(libs.androidx.core.ktx)

             // Ktor
             implementation(libs.ktor.client.okhttp)
        }
        val androidUnitTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
            dependencies {
                implementation(libs.ktor.client.darwin)
            }

        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }

        /*val wasmJsMain by getting{
            dependencies {
                implementation(libs.ktor.client.web)
            }
        }*/
    }
}

compose.experimental {
    web.application {}
}

android {
    compileSdk = (findProperty("android.compileSdk") as String).toInt()
    namespace = "com.retroent.moviebuff"

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    sourceSets["main"].res.srcDirs("src/androidMain/res")
    sourceSets["main"].resources.srcDirs("src/commonMain/resources")

    defaultConfig {
        //applicationId = "com.retroent.moviebuff.android"
        minSdk = (findProperty("android.minSdk") as String).toInt()
        targetSdk = (findProperty("android.targetSdk") as String).toInt()
       // versionCode = 1
      //  versionName = "1.0"
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
}
@McEna posted the shared.gradle file
here is the libs.versions
Copy code
[versions]
coroutines = "1.7.2"
ktor = "2.3.0"
ktor-wasm = "3.0.0-wasm2"
androidx-activityCompose = "1.8.2"
androidx-appcompat = "1.6.1"
androidx-core-ktx = "1.12.0"
imageLoading = "1.5.2"
decompose = "3.0.0-alpha04"
kotlinDateTime = "0.5.0"
compose = "1.5.4"
coil = "3.0.0-SNAPSHOT"
compose-plugin = "1.6.0-alpha01"
kotlin = "1.9.21"
agp = "8.2.1"


[libraries]

androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }

androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core-ktx" }

image-loading = { module = "io.github.qdsfdhvh:image-loader", version.ref = "imageLoading" }

kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinDateTime" }

ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor-wasm" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor-wasm" }
ktor-client-web = { module = "io.ktor:ktor-client-js", version.ref = "ktor-wasm" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor-wasm" }

ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor-wasm" }
ktor-client-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor-wasm" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor-wasm" }

arkivanov-decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose" }
arkivanov-jetbrains-uiext = { module = "com.arkivanov.decompose:extensions-compose", version.ref = "decompose" }

#Image downloading
coil-coil = { group = "io.coil-kt.coil3", name = "coil", version.ref = "coil" }
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
coil-network-ktor = { group = "io.coil-kt.coil3", name = "coil-network-ktor", version.ref = "coil" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
a
@alarochelle actually my problem got resolved by : https://github.com/arkivanov/Decompose/issues/658
487 Views