android build_error ai_generated true

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

Also available as: JSON · Markdown · 中文
85%Fix Rate
87%Confidence
1Evidence
2023-09-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Android Gradle Plugin 7.4.0 active
Android Gradle Plugin 8.0.0 active
Android Gradle Plugin 8.1.0 active

Root Cause

Jetifier cannot map an old support library class to AndroidX because the mapping file is incomplete or the library version is too old.

generic

中文

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

Official Documentation

https://developer.android.com/jetpack/androidx/migrate

Workarounds

  1. 90% success 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`.
    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. 92% success 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.
    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. 85% success 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`.
    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`.

中文步骤

  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`.

Dead Ends

Common approaches that don't work:

  1. Delete .gradle cache and rebuild 95% fail

    Cache is not the issue; the mapping file is missing or library is incompatible.

  2. Add Jetifier mapping manually in gradle.properties: `android.jetifier.blacklist=.*` 80% fail

    Blacklisting doesn't solve missing mapping; it just skips the library, potentially causing runtime errors.

  3. Update all dependencies to latest versions 70% fail

    The specific library 'support-v4.aar' may not have an AndroidX equivalent; updating other deps doesn't help.