简体   繁体   中英

Android Studio isn't indexing commonMain folder after adding any dependencies to its sourceSet

I'm trying to create module with shared code for Android and iOS, but when I add any dependency to commonMain it's stopping to index that folder. If I remove dependencies, everything is okay. gradlew clean doesn't help. How could I resolve this issue?

build.gradle.kts:

object Versions {
    const val coroutinesVersion = "1.5.0-native-mt"
    const val ktorVersion = "1.6.1"
    const val kotlinVersion = "1.5.21"
    const val serializationVersion = "1.2.2"
}

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    kotlin("plugin.serialization")
}

version = "1.0"

kotlin {
    android()

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutinesVersion}")
                implementation("io.ktor:ktor-client-core:${Versions.ktorVersion}")
                implementation("io.ktor:ktor-client-serialization:${Versions.ktorVersion}")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.serializationVersion}")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-android:${Versions.ktorVersion}")
            }
        }
        val androidTest by getting
    }
}

android {
    compileSdk = 32
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 21
        targetSdk = 32
    }
}

Screen of module:

在此处输入图像描述

Problem was with libraries versions. After update to a newer ones everything works fine:)

Newer versions:

object Versions {
    const val coroutinesVersion = "1.6.1"
    const val ktorVersion = "2.0.2"
    const val serializationVersion = "1.3.3"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM