How to avoid migrating to AndroidX in react-native?

Viewed 2115

As Google APIs for Android introduced breaking changes as here I found my self un able to compile my react native android app, there are two things I need to know about:

How to avoid migrating to AndroidX and compile my project as I did before?

For example, when I have this error:

node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/ReactNativeFirebaseAppRegistrar.java:20: error: package android.support.annotation does not exist
import android.support.annotation.Keep;

how would include that missing package into build.gradle of that module?

I tried:

dependencies {
    compile 'com.android.support:support-annotations:27.1.1'
  }

but it did not help..

1 Answers

You can disable or avoid androidX with the following step

go to your android/gradle.properties file and paste or update the following

android.useAndroidX=false
android.enableJetifier=false

Although it does not update libraries we import or install, So all the libraries should be in AndroidX support otherwise project will not compile with this change I'm also having the same issue in my case project is fine but the problem is with the library called mapbox which have not support androidx I post the issue here you can check issue and comments.

Related