Kotlin Multiplatform:无法从另一个模块的 androidMain 源集中引用 commonMain 源集中的类

Rab*_*adi 5 android kotlin-multiplatform kmm

我有两个多平台模块shared以及other一个针对 Android 和 iOS 的标准多平台模板项目。

sharedcommonMain在源集中定义一个类

class SharedGreeting()
Run Code Online (Sandbox Code Playgroud)

othershared在 gradle 文件中设置为依赖如下:

val commonMain by getting {
            dependencies {
                implementation(project(":shared"))
            }
        }
Run Code Online (Sandbox Code Playgroud)

在其androidMain源集中,它尝试引用SharedGreeting某个类 fx:

class AndroidGreeter{
   val foo = SharedGreeting()
}
Run Code Online (Sandbox Code Playgroud)

但无论我尝试什么,当我尝试引用共享类时都会遇到 IDE 错误,并且我必须手动添加导入语句。

不过代码编译和部署没有问题!关于我遗漏或误解的内容有什么想法吗?或者这是 KMM 中的一个错误?

gradle 文件的完整副本other

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

version = "1.0"

kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        framework {
            baseName = "other"
        }
    }
    
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(project(":shared"))
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting
        val androidTest 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)
        }
        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)
        }
    }
}

android {
    compileSdk = 32
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 24
        targetSdk = 32
    }
}
Run Code Online (Sandbox Code Playgroud)

完整的项目源代码: https ://github.com/RabieJradi/kmm_import_error_sample

不幸的是,IDE 建议的添加依赖项的操作没有执行任何操作。 在此输入图像描述