0

In my KMM App trying to collect the state of the data via coroutine StateFlow but it throwing me this error does anyone know what could cause this to happen

Cannot access 'kotlinx.coroutines.flow.Flow' which is a supertype of 'kotlinx.coroutines.flow.StateFlow'. Check your module classpath for missing or conflicting dependencies

var response = viewModel.events.authenticateUser(User(username = "",password = ""))
print(viewModel.stateFlow.value) // When it tries the .value it throws this error

Here is my gradle file

    plugins {
    kotlin("multiplatform")
    id("com.android.library")
    kotlin("plugin.serialization") version "1.4.31"
}

kotlin {
    val ktorVersion = "1.4.0"
    val serializationVersion = "1.0.0-RC"
    val coroutinesVersion = "1.4.3-native-mt"
    android()
    ios {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
                implementation("com.github.bumptech.glide:glide:4.11.0")
                implementation("com.github.bumptech.glide:compiler:4.11.0")
                implementation("io.ktor:ktor-client-android:$ktorVersion")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-ios:$ktorVersion")
            }
        }
        val iosTest by getting
    }
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
    }
}

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework =
        kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)
Chinthaka Devinda
  • 997
  • 5
  • 16
  • 36
  • Is it a compilation error or just an IDE error? [There are](https://youtrack.jetbrains.com/issue/KT-31052) a number of issue regarding the wrong IDE error. – esentsov Apr 03 '21 at 03:24
  • @esentsov it's strange seems sounds like an IDE error to me it mixes up dependencies it seems :( – Chinthaka Devinda Apr 03 '21 at 04:09
  • Invalidate cache and restart didn't help too (Tried cleaning up build folders and .gradle folders manually still the same – Chinthaka Devinda Apr 03 '21 at 04:28

0 Answers0