android
build_error
ai_generated
true
使用 Jetifier 转换工件 'support-v4.aar' 失败。原因:找不到支持类 'android/support/v4/app/FragmentActivity' 的映射
Failed to transform artifact 'support-v4.aar' using Jetifier. Reason: Cannot find a mapping for support class 'android/support/v4/app/FragmentActivity'
ID: android/gradle-transform-error-jetifier-missing-mapping
85%修复率
87%置信度
1证据数
2023-09-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Android Gradle Plugin 7.4.0 | active | — | — | — |
| Android Gradle Plugin 8.0.0 | active | — | — | — |
| Android Gradle Plugin 8.1.0 | active | — | — | — |
根因分析
Jetifier 无法将旧的支持库类映射到 AndroidX,因为映射文件不完整或库版本太旧。
English
Jetifier cannot map an old support library class to AndroidX because the mapping file is incomplete or the library version is too old.
官方文档
https://developer.android.com/jetpack/androidx/migrate解决方案
-
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`.
-
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.
-
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
95% 失败
Cache is not the issue; the mapping file is missing or library is incompatible.
-
Add Jetifier mapping manually in gradle.properties: `android.jetifier.blacklist=.*`
80% 失败
Blacklisting doesn't solve missing mapping; it just skips the library, potentially causing runtime errors.
-
Update all dependencies to latest versions
70% 失败
The specific library 'support-v4.aar' may not have an AndroidX equivalent; updating other deps doesn't help.