I'm beginner in Kotlin native and my objective is build a lib that our Rest APIs include it and I use it on iOS and Android.
I knew ktor
and implemented this in my project but when I run build
project by Gradle
get exception where I use objects of kotr
:
> Task :apiCore:androidProcessResources NO-SOURCE
> Task :apiCore:compileKotlinAndroid UP-TO-DATE
> Task :apiCore:androidMainClasses UP-TO-DATE
> Task :apiCore:androidJar UP-TO-DATE
> Task :apiCore:compileKotlinIOS
src/commonMain/kotlin/APICore.kt:3:8: error: unresolved reference: io
import io.ktor.client.HttpClient
^
src/commonMain/kotlin/APICore.kt:4:8: error: unresolved reference: io
import io.ktor.client.request.get
^
src/commonMain/kotlin/APICore.kt:10:17: error: unresolved reference:
HttpClient
val client = HttpClient()
^
Execution failed for task ':apiCore:compileKotlinIOS'.
> Process 'command '/Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with
non-zero exit value 1
and my Gradle
for multiplatform module:
sourceSets {
commonMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
implementation("io.ktor:ktor-client-core:1.1.1")
}
androidMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib'
implementation ("io.ktor:ktor-client-android:1.1.1")
}
iosMain.dependencies{
implementation "io.ktor:ktor-client-ios:1.1.1"
}
}