jean
08/19/2020, 12:21 PMFailed to find HTTP client engine implementation in the classpath: consider adding client engine dependency. See <https://ktor.io/clients/http-client/engines.html>
I notice some changes in the doc, as far as I remember, that page had a comment regarding multiplatform saying devs could just omit to specify an engine when used in mpp context. I guess it’s not the case anymore? I plan to share an api client based on ktor client to android and ios, should I change to something like that :
class ApiClient(
private val engine: HttpClientEngine
) {
private val client = HttpClient(engine)
}
then android can instantiate this by passing CIO
and iOS passing Ios
e5l
08/19/2020, 12:22 PMjean
08/19/2020, 12:26 PMval commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
}
}
then I have a specific target for both android and ios :
val clientCommon by creating {
dependsOn(commonMain)
kotlin.srcDir("src/clientCommon/kotlin")
resources.srcDir("src/clientCommon/resources")
dependencies {
implementation("io.ktor:ktor-client-core:1.4.0")
implementation("io.ktor:ktor-client-json:1.4.0")
implementation("io.ktor:ktor-client-serialization:1.4.0")
implementation("com.russhwolf:multiplatform-settings:0.6.1")
implementation("com.russhwolf:multiplatform-settings-no-arg:0.6.1")
}
}
android, I used to have a specific android dependency when using 1.3.72, I removed it since 1.4.0 suggest to only have a single dependency in common, is that why it fails?
val androidMain by getting {
dependsOn(clientCommon)
dependencies {
}
}
ios, I havent implemented the app yet so it’s empty for now
val iosMain by getting {
dependsOn(clientCommon)
dependencies {
}
}
e5l
08/19/2020, 12:27 PMe5l
08/19/2020, 12:28 PMHttpClient()
call should work without explicit engine in commonjean
08/19/2020, 12:43 PMe5l
08/19/2020, 12:44 PMjean
08/19/2020, 12:46 PMcall should work without explicit engine in commonHttpClient()
e5l
08/19/2020, 12:46 PMe5l
08/19/2020, 12:47 PMjean
08/19/2020, 12:48 PMBut
I though you were saying that without specific dependencies in android/ios scope, it should still work.
all good then, thanks 🙂e5l
08/19/2020, 12:49 PMrudolf.hladik
08/19/2020, 1:19 PMe5l
08/19/2020, 1:20 PMrudolf.hladik
08/19/2020, 1:21 PMe5l
08/19/2020, 1:22 PMktor-client-cio
rudolf.hladik
08/19/2020, 1:22 PMJohn O'Reilly
08/19/2020, 1:57 PMktor-client-cio
in common if that's engine you're going to use for all platforms (if that's possible that is)?e5l
08/19/2020, 1:57 PMe5l
08/19/2020, 1:58 PMCIO
doesn’t work on js yetJohn O'Reilly
09/01/2020, 3:20 PMCIO
.....works fine in simulator but crashes on deviceJohn O'Reilly
09/01/2020, 3:20 PMe5l
09/02/2020, 10:09 AMJohn O'Reilly
09/02/2020, 10:10 AMNeal Sanche
09/02/2020, 2:48 PM