docs(lesson6): make dependency section student copy-paste friendly
Build Android app / Build (push) Has been cancelled
Build iOS app / Build (push) Has been cancelled
Template Cleanup / Template Cleanup (push) Has been cancelled

This commit is contained in:
xiaobai committed 2026-03-04 21:15:41 +08:00
1 parent 2ac859f46b
commit fb828b8796
1 file changed
+19 -8
@@ -55,16 +55,27 @@ kmp-mini-shopping/
> 目标:让 shared 能发请求、能序列化、能存本地。
### 1. `shared/build.gradle.kts`
确认(或添加)这些依赖:
直接在 `kotlin { sourceSets { ... } }` 里按下面写(可照抄):
- `ktor-client-core`
- `ktor-client-content-negotiation`
- `ktor-serialization-kotlinx-json`
- `multiplatform-settings-no-arg`
- `kotlinx-serialization`
```kotlin
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.ktor:ktor-client-core:3.1.3")
implementation("io.ktor:ktor-client-content-negotiation:3.1.3")
implementation("io.ktor:ktor-serialization-kotlinx-json:3.1.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.8.1")
implementation("com.russhwolf:multiplatform-settings-no-arg:1.1.1")
}
Android 侧引擎(`shared/androidMain`)需要:
- `ktor-client-okhttp`(或 Android 引擎)
androidMain.dependencies {
implementation("io.ktor:ktor-client-okhttp:3.1.3")
}
}
}
```
> 如果你项目当前版本不一致,以你项目里已锁定版本为准。
### 2. Ktor 官方文档(课堂可直接贴)
- Ktor Multiplatform Client 官方教程: