March 13, 2019

Migration to androidX

If you’ve ever worked on an android project you must have had the chance to fight the libraries version. Android tried to split the  support libraries into smaller pieces, and we got some modularisation, (,,  but this approach has made things more complicated because of the versions. We are well aware of the mess with the backwards-compatibility-libraries v4, v7, v13, v8, v?.Android decided to make androidx to stop this version confusion so every support library like is now androidx.recyclerview.widget.AsyncDifferConfig.

When we talk about react native android part, first we need to make sure we have compileSdkVersion 28 in android/build.gradle file.
Then in android/ we need to add these two lines of code :

After this, we need to go to android studio and pick

Migration to androidX

Refactor > Migrate to AndroidX. 

This will convert your app to androidX but we are currently talking about React Native and that means that we have multiple third-party libraries that also needs to be updated. Jetifier is the answer.

After refactoring with the android studio, you should install jetifier.
1. npm install –save-dev jetifier
2. npx jetify

After this, you can run react-native run-android and that’s it.

you can also add npx jetify to postinstall script like this: 

androidX after refactoring run npx jetify


All future Android development will be going into AndroidX. It will be easier to maintain and write code without the mess that was caused by the versions. We hope that these tips will make your migration easier.


Author: Dev Team
Like this article? Share it!