Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Build fails: android.support.v4.app does not exist

Errorpackage android.support.v4.app does not exist

Short answer

The old support library is gone from your build, but your code or a library still imports android.support classes. Change your own imports to the AndroidX equivalents. If the import is inside a third-party library you cannot edit, update that library, or enable Jetifier as a last resort.

  • Applies to Android Gradle Plugin 8, AndroidX, Android Studio
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out whether the import is in your code or in a dependency. Search your source first.

    grep -rn "android.support" app/src
  2. 2Match what you see, then jump to its fix

    1. 1The failing file is in your app/src folderYour own code still imports the support libraryFix
    2. 2The failing file is inside a library, not in your sourceA dependency was built against the support libraryFix

What does the error look like?

  • package android.support.v4.app does not exist

Cause 1 of 2

Your own code still imports the support library

1Check

AndroidX replaced the support library. Only package and artifact names changed; class, method and field names did not.

grep -rln "android.support" app/src

2Fix

Replace each import with its AndroidX class from Google's class mapping table, and add the matching AndroidX dependency. For example android.support.v4.app.Fragment becomes androidx.fragment.app.Fragment.

// before
import android.support.v4.app.Fragment;
// after
import androidx.fragment.app.Fragment;

3Verify

Rebuild; the error for that file is gone.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

A dependency was built against the support library

1Check

Most libraries already support AndroidX. An old library that does not needs updating.

./gradlew :app:dependencies --configuration debugRuntimeClasspath

2Fix

Update the library to a version that uses AndroidX. If none exists, turn on Jetifier, which rewrites old binaries, knowing Google says it can slow builds and should be used only when necessary.

# gradle.properties
android.enableJetifier=true

3Verify

Sync and rebuild.

./gradlew clean assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Use AndroidX libraries only in new code and new dependencies.
  • Check Build Analyzer's Jetifier check before keeping enableJetifier on.
  • Replace unmaintained libraries instead of patching them with Jetifier.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.