docs(lesson6): clarify libs.ktor.client.content.negotiation naming and sync tips
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 19:07:37 +08:00
1 parent 5406a7de02
commit b9e621c9e0
1 file changed
+28 -1
@@ -69,7 +69,34 @@ android:usesCleartextTraffic="true"
Android 侧引擎(`shared/androidMain`)需要: Android 侧引擎(`shared/androidMain`)需要:
- `ktor-client-okhttp`(或 Android 引擎) - `ktor-client-okhttp`(或 Android 引擎)
> 你项目里如果用了 `libs.versions.toml`,按版本目录方式加;课堂不纠结版本细节。 ### 2. Ktor 官方文档(课堂可直接贴)
- Ktor Multiplatform Client 官方教程:
`https://ktor.io/docs/client-create-multiplatform-application.html`
### 3. 为什么是 `libs.ktor.client.content.negotiation`?
这是 **Version Catalog(`libs.versions.toml`)自动生成 accessor** 的规则。
例如你在 TOML 里定义:
```toml
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
```
Gradle 会把 `-` 转成 `.`,所以在 Kotlin DSL 里引用变成:
```kotlin
implementation(libs.ktor.client.content.negotiation)
```
同理:
- `ktor-client-core` -> `libs.ktor.client.core`
- `ktor-serialization-kotlinx-json` -> `libs.ktor.serialization.kotlinx.json`
> 如果你“搜不到” `libs.ktor.client.content.negotiation`,先检查:
> 1) `gradle/libs.versions.toml` 是否存在该 key;
> 2) key 名字是否完全一致;
> 3) 重新 Sync Gradle(IDE 才会刷新自动生成的 `libs` 访问器)。
--- ---