React-native-gesture-handler: Project won't compile when androidx and jetifier are enabled (SDK build tools >28.0.0)

Created on 22 Dec 2018  路  11Comments  路  Source: software-mansion/react-native-gesture-handler

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

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

Android

Most helpful comment

You need this tool: https://www.npmjs.com/package/jetifier
and some context here https://github.com/react-native-community/discussions-and-proposals/issues/129

Basically it goes trough node_modules and migrate all imports. e.g. changeimport android.support.v4.util.Pools; to import androidx.core.util.Pools;

All 11 comments

me too

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

got the same problem above

410, #460, and #524 all fix this but there seems to be issues with Travis not building the app with the required changes.

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

The same issue here, derived from integrating Firebase's libraries

The same issue here

Why in Android SDK 28 the support library is being phased out? and why use Androidx?

Same issue here, any ideia about the solution?

You need this tool: https://www.npmjs.com/package/jetifier
and some context here https://github.com/react-native-community/discussions-and-proposals/issues/129

Basically it goes trough node_modules and migrate all imports. e.g. changeimport android.support.v4.util.Pools; to import androidx.core.util.Pools;

Why in Android SDK 28 the support library is being phased out? and why use Androidx?

So that we can easily differentiate between packages which are shipped with Android and the packages available in your Application Package Kit(APK)

Should be resolved in later releases.

Was this page helpful?
0 / 5 - 0 ratings