https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Gurupad Mamadapur [FH]

12/23/2019, 2:54 PM
Hi, for some reason I cannot resolve a dependency in the common sourceSet in mpp module. More specifically it is a ktor-core dependency. Here is the build.gradle file -
Copy code
plugins {
    id "com.android.library"
    id 'org.jetbrains.kotlin.multiplatform'
}

repositories {
    mavenCentral()
}

android {
    compileSdkVersion(28)
    buildToolsVersion = "28.0.3"
    defaultConfig {
        minSdkVersion(16)
        targetSdkVersion(28)
    }
}

kotlin {
    android()
    js {
        browser {

        }
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                implementation "io.ktor:ktor-client-core:$ktorVersion"
            }
        }
        androidMain {
            dependencies {
                implementation kotlin('stdlib')
            }
        }
        jsMain {
            dependencies {
                implementation kotlin('stdlib-js')
            }
        }
    }
}
Here is the root build.gradle -
Copy code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.3.61'

    repositories {
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

ext {
    ktorVersion = "1.3.0-rc"
}
Error is -
Copy code
> Task :shared:compileDebugKotlinAndroid FAILED
e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (1, 23): Unresolved reference: HttpClient
e: /Users/fabhotels/Development/testmpp/shared/src/commonMain/kotlin/common.kt: (3, 18): Unresolved reference: HttpClient
The sample project is available here - https://github.com/Protino/testmpp/tree/sample/ktor
k

Kris Wong

12/23/2019, 3:06 PM
you also need the target-specific dependencies
👍 1
ktor-client-android, ktor-client-ios
i assume there's one for js? unsure on that
g

Gurupad Mamadapur [FH]

12/23/2019, 3:08 PM
Yep there is, let me try that.
@Kris Wong Works now, Thank you!
🍻 1
9 Views