Project won’t compile when androidx and jetifier are enabled (SDK build tools >28.0.0)

As of version 28.0.0 of the Android SDK build tools the support library is being phased out in favour of Androidx. Jetifier attempts to bridge this gap by converting external packages to use Androidx.

When both Androidx and Jetifier are enabled in a project’s gradle.properties (see below), jetifier (presumably) prevents the support library from being included in the project locally, and therefor into node_modules

# gradle.properties
android.useAndroidX=true
android.enableJetifier=true

The result is an error preventing compilation:

node_modules/react-native-gesture-handler/[...]/RNGestureHandlerEvent.java:3: error: package android.support.v4.util does not exist
import android.support.v4.util.Pools;
                              ^

This can be fixed by upgrading to androidx. Replacing the offending line (and anywhere else Pools is being imported) with import androidx.core.util.Pools; would do the trick.

Of course that would cause people who are not on 28.x.x headaches. And this isn’t a problem if you aren’t using Jetifier (I can get it to compile past the error by turning it off, but am then faced with having to downgrade as whole).

3 thoughts on “Project won’t compile when androidx and jetifier are enabled (SDK build tools >28.0.0)

  1. when i use androix and
    set
    # gradle.properties android.useAndroidX=true android.enableJetifier=true

    got the same problem above

  2. react-gesture-handler-handler breaks in react-native 0.60.0-rc.0 because of the move to Androidx.
    Perhaps a good idea would be to move forward with the changes suggested in the #410 in time of 0.60.0’s release