相关疑难解决方法(0)

无法在 Android Studio 中将 io.ktor 导入到 KMM 的公共模块

所以我是 Kotlin Multiplatform Mobile 和一般移动开发的新手。我正在尝试按照KMM 教程中的本教程在我的项目中使用 Ktor。

添加依赖后,如下图build.gradle.kts(commonMain、androidMain、iosMain的依赖):

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

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

kotlin {
    android()
    ios {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }

    val ktorVersion = "1.5.2"

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-core:$ktorVersion")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation ("io.ktor:ktor-client-android:$ktorVersion")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            } …
Run Code Online (Sandbox Code Playgroud)

kotlin android-gradle-plugin ktor kotlin-multiplatform ktor-client

3
推荐指数
1
解决办法
510
查看次数