Migrating React Native App to AndroidX

In this post, we will learn to migrate React Native application to AndoridX. Before starting, let me give you a brief introduction about Jetpack.

What is Android Jetpack?

Android Jetpack is the next generation of Android components, bringing together the benefits of the Support Library – backwards compatibility and immediate updates to a larger set of components, making it quick and easy to build robust, high quality apps. Android Jetpack manages activities like background tasks, navigation, and lifecycle management, so you can eliminate boilerplate code and focus on what makes your app great.

To start with the migration, firstly, edit gradle.properties of React Native application to add the following lines:

android.useAndroidX=true
android.enableJetifier=true

Next, Install jetifier package executing following command:

$ npm install --save-dev jetifier

Call npx jetify to migrate all node_modules to AndroidX, as follows:

$ npx jetify

And finally run your application using npx:

npx react-native run-android
Advertisements