package android.support.v4.util does not exist

In my case, the solution was eventually found as documented here:

  • Make sure you have downloaded the Android Support Library using the SDK Manager.
  • Create a libs/ directory in the root of your application project.
  • Copy the JAR file from your Android SDK installation directory (e.g., <sdk>/extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory.

If you're using Gradle, I had to also add this line to the dependencies section of my inner build.gradle, the file where you specify your minSdkVersion and targetSdkVersion:

dependencies {
  compile "com.android.support:support-v4:19.0.+"
}

I believe the '19' is supposed to be whatever your compileSdkVersion. If I'm wrong, it will tell you what it's supposed to be.

For those importing the support libraries using gradle like this:

// compat libraries
compile 'com.android.support:support-v4:23.2.0' // v4
compile 'com.android.support:appcompat-v7:23.2.0' // v7
compile 'com.android.support:support-v13:23.2.0' //v13

Remember to remove this all*.exclude module: 'support-v4' from configurations

configurations {
    //all*.exclude module: 'support-v4'
}

...might have been a dummy mistake from my part though :)

After trying tweaking build.gradle different ways, ended up with solution found here: https://github.com/kmagiera/react-native-gesture-handler/issues/394#issuecomment-508358572

in short - you can solve it with jetifier:

npm install --save-dev jetifier npx jetify

From the package docs:

If you use React Native modules with native Java code that isn't converted to AndroidX, and your app is AndroidX, you probably need this.

In my case I was porting an Android Googlemaps app API1 to API2, and after many hours I realized I was not adding

C:\Program Files\..(your_path_)..
  ..\adt-bundle-windows-x86_64\sdk\extras\android\support\v4

to External Libraries..

Hope this helps

ttguy

craned's answer:

dependencies {
    compile "com.android.support:support-v4:19.0.+"
}

worked for me. But (in my case at least) the '19' should match the compileSdkVersion

Go to your Android SDK's directory and:

jar tvf ./extras/android/support/v13/android-support-v13.jar |grep v4.*util

And within this jar file you can see one of the classes (under v4/util) you have used in your applications.

     0 Wed Mar 26 20:29:48 SGT 2014 android/support/v4/util/
  3373 Wed Mar 26 20:29:48 SGT 2014 android/support/v4/util/ArrayMap.class
  5329 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections.class
  1625 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/ContainerHelpers.class
  3677 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections$KeySet.class
  1220 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/DebugUtils.class
  3435 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/AtomicFile.class
  1287 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/LogWriter.class
  3701 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections$ValuesCollection.class
  4446 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections$EntrySet.class
  5910 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/SparseArrayCompat.class
  3273 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/TimeUtils.class
  5776 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/LongSparseArray.class
  5680 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/LruCache.class
  3341 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections$MapIterator.class
  1575 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/MapCollections$ArrayIterator.class
  2439 Wed Mar 26 20:29:48 SGT 2014 android/support/v4/util/ArrayMap$1.class
  8611 Wed Mar 26 20:29:46 SGT 2014 android/support/v4/util/SimpleArrayMap.class

So the error "package android.support.v4.util does not exist" simply means you have to copy the above jar file to your libs subdirectory and recompile.

In my case the problem was referencing the jar from sdk installation folder, copying the jar to project's libs folder adding to build path actually resolved the issue.

In my case with Android Studio, this error appeared in the middle of a working project and refused to disappear despite much fooling around. I finally forced a Gradle Sync operation by adding a single space character to a Gradle file. The Gradle Sync fixed it instantly.

add dependency

dependencies { compile 'com.android.support:support-v4:+'}

Change Build Tool

 dependencies {  classpath 'com.android.tools.build:gradle:2.3.0'}

Worked for me.

Step-1: Open Project in AndroidStudio3.3 or above, wait until loading of the project completes.

Step-2: Right click 'app' -> Refactor -> Migrate to AnroidX

Step-3: Review the changes in AndroidStudio console below and click 'Do Refactor'

The issue will be fixed.