# 使用 Jetifier 转换工件 'support-v4.aar' 失败。原因：找不到支持类 'android/support/v4/app/FragmentActivity' 的映射

- **ID:** `android/gradle-transform-error-jetifier-missing-mapping`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Jetifier 无法将旧的支持库类映射到 AndroidX，因为映射文件不完整或库版本太旧。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Android Gradle Plugin 7.4.0 | active | — | — |
| Android Gradle Plugin 8.0.0 | active | — | — |
| Android Gradle Plugin 8.1.0 | active | — | — |

## 解决方案

1. ```
   Exclude the problematic library from Jetifier: in build.gradle, add `android.jetifier.blacklist = ["support-v4.aar"]` and manually migrate its usage to AndroidX equivalents like `androidx.legacy:legacy-support-v4:1.0.0`.
   ```
2. ```
   Update the library to an AndroidX version: replace `com.android.support:support-v4:28.0.0` with `androidx.legacy:legacy-support-v4:1.0.0` in dependencies.
   ```
3. ```
   Add a custom Jetifier mapping: create a file `jetifier-mappings.txt` with `android/support/v4/app/FragmentActivity -> androidx/fragment/app/FragmentActivity` and reference it via `android.jetifier.mappingsFile`.
   ```

## 无效尝试

- **Delete .gradle cache and rebuild** — Cache is not the issue; the mapping file is missing or library is incompatible. (95% 失败率)
- **Add Jetifier mapping manually in gradle.properties: `android.jetifier.blacklist=.*`** — Blacklisting doesn't solve missing mapping; it just skips the library, potentially causing runtime errors. (80% 失败率)
- **Update all dependencies to latest versions** — The specific library 'support-v4.aar' may not have an AndroidX equivalent; updating other deps doesn't help. (70% 失败率)
