在 settings.gradle
文件中修改共享模块的名称,将其包含在另一个项目中。以下是一个示例:
include ':shared'
project(':shared').projectDir = file('../shared')
注意,../shared
应该是指向共享模块目录的正确路径。随后,您需要将依赖项添加到build.gradle
文件中,如下所示:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
// Add dependencies for other libs that you use in shared module
// implementation "com.squareup.okhttp3:okhttp:4.9.1"
// implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3"
// others
}
重新构建并同步项目后,您应该能够在Android Studio IDE中正确识别commonMain
所实现的依赖项了。