React Native: Migrate to AndroidX

蹲街弑〆低调 提交于 2019-12-04 07:18:40

I ran into the same problem yesterday and finally figured it out, the reason of the above error is after migrating your android project to androidx, many of your react-native libraries ship native Java code and have not updated, I was able to solve it by using this library jetifier simply by running

npm i --save-dev jetifier
npx jetify

but in my case there were still some libraries causing some issues such us react-native-fast-image as a workaround, I created a gradle.properties inside /node_modules/react-native-fast-image/android and deactivated AndroidX and Jetifier for this module:

android.useAndroidX=false
android.enableJetifier=false

The answer that Ahmed posted is a great solution once you've migrated to AndroidX. In my case I didn't want to quite yet and found out that only one library in my application was using AndroidX from this thread

In short my solution was to simply yarn upgrade react-native-device-info@latest The app build as expected after rebuilding it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!