react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.66k stars 126 forks source link

AndroidX Migration Plan #129

Closed matt-oakes closed 5 years ago

matt-oakes commented 5 years ago

Introduction

React Native 0.60 will move from using the Support Library to AndroidX. These are mostly the same library, however the artifacts names and package names have all changed. Google has stopped supporting the support library (ha) and will only be releasing updates to AndroidX.

Details from Google.

With this change, React Native apps will need to begin using AndroidX themselves. They cannot be used side-by-side in one app, so all of the app code and dependency code needs to be using one or the other.

A normal native app can use the Jetifier tool to migrate. This goes through all of their dependencies and changes any references to the support library to AndroidX.

Jetifier will not work for React Native projects as it only works on "packaged artifacts". Almost all React Native dependencies come in the form of a reference to the library source code. These are not migrated by Jetifier.

The Core of It

We are going to have lots of reported issues where developers Android apps will not build because some of their dependencies are using AndroidX and some are using the support library.

The "best" solution is for all libraries to release a version which has migrated to AndroidX and the app developer can then upgrade all of their dependencies at once. This would mean, however, that users who want to get bug fixes for that library would need to migrate their app to AndroidX. This, in turn, means that if just one of their dependencies is not migrated to AndroidX, they are locked into using <=RN 0.59 and cannot use new versions of libraries which have migrated.

Most React Native libraries do not need to use the support library, however, there are many that do and not all are actively maintained.

Discussion points

How can we help developers with this problem?

benoitdion commented 5 years ago

most windows devs have WSL installed these days so there's a good chance it'll work

mikehardy commented 5 years ago

It may be that we simply have to say "you need WSL"? But if someone could test it actually works with WSL so we aren't making things worse that would be huge. I don't have a windows dev rig, just a tiny VM for windows-necessary things

laurent22 commented 5 years ago

WSL is what I used to run jetifier and it works fine.

To be precise: I always manage npm dependencies from the win32 console because WSL is way too slow. So I've first installed jetifier from the Windows console, then I ran the the jetify command from WSL. It processed all the files and the app built fine afterwards.

mikehardy commented 5 years ago

@laurent22 could you please check https://github.com/mikehardy/jetifier/issues/10 and maybe propose the exact steps you used as a note in the README for windows people? I don't have a windows dev rig but I know it is a massive portion of the userbase, I'd like them to be unblocked as well

laurent22 commented 5 years ago

@mikehardy, unfortunately Windows decided to restart my computer while I was away so I've lost the history of the exact commands I used. If I remember correctly I've installed it globally then ran it, but I'll confirm later, as I expect I'll need to jetify the project again soon.

mikehardy commented 5 years ago

@laurent22 Interesting, just got a success report from the person that opened that issue after they installed it locally vs globally. I'll hide these comments here now as it appears to work, but any :hearts: you can give to the docs for windows will be appreciated by everyone, thanks!

robertying commented 5 years ago

I was trying to patch almost every module by hand yesterday. 😅

@mikehardy you really saved my day! 👍

phr0zenx commented 5 years ago

I'm one of those unfortunates that's stuck on using WSL.

All i'm getting are errors such as follows, which i assume is because of pathing issues.


sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/Screen.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-swipeable-row/.idea/inspectionProfiles/Project_Default.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-swipeable-row/.idea/misc.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-swipeable-row/.idea/modules.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-swipeable-row/.idea/vcs.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-swipeable-row/.idea/workspace.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-timeline-feed-oeuvre/node_modules/react-native-vector-icons/android/src/main/AndroidManifest.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-timeline-feed-oeuvre/node_modules/react-native-vector-icons/android/src/main/java/com/oblador/vectoricons/VectorIconsModule.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-timeline-feed-oeuvre/node_modules/react-native-vector-icons/android/src/main/java/com/oblador/vectoricons/VectorIconsPackage.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-vector-icons/android/src/main/AndroidManifest.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-vector-icons/android/src/main/java/com/oblador/vectoricons/VectorIconsModule.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/react-native-vector-icons/android/src/main/java/com/oblador/vectoricons/VectorIconsPackage.java
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
jetifying file node_modules/xmldoc/examples/test.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory```
mikehardy commented 5 years ago

@phr0zenx have you installed globally or locally? I have mixed reports on that but installing locally was the most solid report. Other than that I'm sorry I can't reproduce to support and fix, but I can say that I have 2 solid reports that it can work. Sometimes (when I'm tackling something irritating and subtle) just knowing it is possible is enough to push through and find the reason + fix it. Good luck

phr0zenx commented 5 years ago

@mikehardy Installed it globally on npm in WSL.

chakrihacker commented 5 years ago

I think it's a problem from WSL file permissions, @phr0zenx can you try using powershell or cmd

mikehardy commented 5 years ago

the success report was installing locally using regular cmd to manage dependencies, then using it (post install) in WSL. 🤞

phr0zenx commented 5 years ago

@mikehardy Uninstalled globally, installed locally, switched to Windows Subsystem for Linux bash, and executed. No longer reports error. Will report if this succeeds. I'm hopeful.

phr0zenx commented 5 years ago

@mikehardy So... after running jetify successfully, i got the following error when trying to compile. It indicates it was updated to androidX but...


C:\repo\mobile\node_modules\lottie-react-native\src\android\src\main\java\com\airbnb\android\react\lottie\LottieAnimationViewManager.java:8: error: package androidx.core.view does not exist
import androidx.core.view.ViewCompat;
                         ^
C:\repo\mobile\node_modules\lottie-react-native\src\android\src\main\java\com\airbnb\android\react\lottie\LottieAnimationViewManager.java:118: error: cannot find symbol
            if (ViewCompat.isAttachedToWindow(view)) {
                ^
  symbol: variable ViewCompat
C:\repo\mobile\node_modules\lottie-react-native\src\android\src\main\java\com\airbnb\android\react\lottie\LottieAnimationViewManager.java:144: error: cannot find symbol
            if (ViewCompat.isAttachedToWindow(view)) {
                ^
  symbol: variable ViewCompat
Note: C:\repo\mobile\node_modules\lottie-react-native\src\android\src\main\java\com\airbnb\android\react\lottie\LottieAnimationViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors

FAILURE: Build failed with an exception.```
mikehardy commented 5 years ago

@phr0zenx this actually looks exactly like success to me - you've been jetified, but your project isn't converted to AndroidX - you have to actually change your build.gradle to include the androidx.core library dependency etc. I think this is a success report, but still some work in your project - hopefully easily solved on your part

phr0zenx commented 5 years ago

@mikehardy Appreciate the help, any idea how i can finish this up? With the build.gradle thing.

Already tried adding android.useAndroidX=true android.enableJetifier=true to gradle.properties.

mikehardy commented 5 years ago

@phr0zenx you must use this library as a dependency in android/app/build.gradle https://developer.android.com/jetpack/androidx/releases/core#1.0.2

It'll be one of your normal implementation dependencies, altered from the previous support definition like https://github.com/react-native-community/react-native-camera/pull/2068/files

phr0zenx commented 5 years ago

For those who are as clueless as i am with regards to above instructions, i've found something more straightforward and worked for me. Hopefully, it'll help you too.

https://github.com/react-native-community/react-native-camera/pull/2068/files#diff-88e660a2f349ee917b92283ea3bd1d59

mikehardy commented 5 years ago

Okay, the Jetifier tool now has reverse mode in addition to forward mode

There are no open issues in the repository and it's had a performance enhancement pass, it's pretty quick now

I have CI enabled for it to prove it works with a pretty big test suite including all the problem repositories from the androidx play dependencies release

Basically at any time now you can either have an AndroidX app use non-AndroidX react-native dependencies, or you can have a non-AndroidX app use AndroidX dependencies.

There are alternative implementations of the core transform in javascript and python and we could swap one in if we want to, now that there's a good test suite, but someone else can do that ;-)

I think it's basically good to go, and RN0.60 won't blow up people with native android libraries anymore

khat33b commented 5 years ago

My assembleDebug ran without any errors but when I tried to run react-native run-android, I get the following error:

2019-06-21 16:52:51.934 17537-17604/com.testapp E/SoLoader: Error when loading lib: dlopen failed: library "libjsc.so" not found lib hash: 83f1717c1dc187d9f252a9f1fc66d430 search path is /data/app/com.testapp-unOaxqpsal4ctIdlzWXZmg==/lib/arm
2019-06-21 16:52:51.934 17537-17604/com.testapp E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found

    --------- beginning of crash
2019-06-21 16:52:51.936 17537-17604/com.testapp E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.testapp, PID: 17537
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.react.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:19)
        at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:29)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
        at java.lang.Thread.run(Thread.java:764)

I have added this code in android.defaultConfig in build.gradle but still the error persists:

        ndk {
            abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
        packagingOptions {
            pickFirst 'lib/x86_64/libjsc.so'
            pickFirst 'lib/arm64-v8a/libjsc.so'
            exclude "lib/arm64-v8a/libimagepipeline.so"
            exclude "lib/arm64-v8a/librealm-jni.so"
        }
khat33b commented 5 years ago

I copy my JS resources using: react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

Running assembleRelease gives the error:

> Task :app:mergeReleaseResources FAILED
/home/testapp/android/app/src/main/res/raw/package.json: Error: package is not a valid resource name (reserved Java keyword)
robertying commented 5 years ago

@khat33b take a look at https://github.com/facebook/react-native/issues/25325 for your second issue

khat33b commented 5 years ago

@robertying I had deleted the drawable and raw folders which are generated from the first command. Running react-native run-android --variant=release also gives the same error.

robertying commented 5 years ago

@khat33b the second error was caused by some changes in metro bundler. You can modify files by hand to get around it for now. See https://github.com/facebook/metro/pull/420

khat33b commented 5 years ago

@robertying That solved the issue. But now even in the release APK, the first problem is occurring: library "libjsc.so" not found.

raphaeleidus commented 5 years ago

@mikehardy in your most recent update https://github.com/react-native-community/discussions-and-proposals/issues/129#issuecomment-504169271 You seem to conclude that everything is good now. Does this mean we should not start updating libraries to publish AARs and support AndroidX natively? Or when we update we can just do a single AAR and not the split support/X approach mentioned earlier. I was hoping to start submitting PRs to libs next week if it is still needed/recommended.

mikehardy commented 5 years ago

@raphaeleidus - thanks for asking. I think everything is good now. What happened over time was that we learned some libraries generate code at build or install time, which made me realize we couldn't rely on conversion-pre-distribution for libraries, we needed to convert-at-install or convert-at-build. So this week I implemented source translation in the jetifier package and I think that is sufficient for AndroidX apps using support-library modules, or for support-library apps using AndroidX modules.

I think the only case libraries need a patch now is if the library distributes an AAR/JAR/ZIP normally already, and the library converts to AndroidX. In that case, for support-library apps the app will be "stranded" on the last pre-AndroidX AAR unless the library also publishes a reverse-jetified AAR.

For that case the library would need a patch to use bob in reverse-jetify mode as implemented by @matt-oakes in the bob tool by @satya164: https://github.com/react-native-community/bob/blob/master/README.md#L44 and then publish that support-library artifact alongside the normal (now AndroidX) artifact

If you were already preparing to make PRs, perhaps you could take some time to think through what I wrote above to double-check my thinking, and then if you are aware of libraries that publish AARs normally you could try a PR for them that converts them to AndroidX at the same time it integrates bob for a reverse-jetified AAR artifact, and see if a support-library react-native app can still successfully use the library via the reverse-jetified dependency?

mikehardy commented 5 years ago

@khat33b please try forking https://github.com/mikehardy/rn-androidx-demo and modifying https://github.com/mikehardy/rn-androidx-demo/blob/master/make-demo.sh to reproduce the error. That's how I'm proving this works. So far it has found 2 underlying library errors, and one AndroidX guidance issue we needed to work around so it's an effective diagnostic and correctness tool.

khat33b commented 5 years ago

@mikehardy I tried running that demo. It ran properly but it installs 0.59.9 version of React Native. When upgrading to 0.60-RC2, rerunning the jetifier and running the app, a lot of cannot find symbol errors in the dependenices popped up.

mikehardy commented 5 years ago

@khat33b please post URLs to your forks of rn-androidx-demo and jetifier and we can diagnose

khat33b commented 5 years ago

@mikehardy This is my generated project: https://github.com/khat33b/rn-androidx-demo

mikehardy commented 5 years ago

@khat33b okay - I’d like to see the make-demo.sh modification that produces the error, not a generated repo - I’ve logged https://github.com/khat33b/rn-androidx-demo/issues/1 - let's discuss it there, and once we have something we can carry it back here

FrankGoortani commented 5 years ago

I'm stuck with this and need to do a release on my app. Is there a way NOT TO MIGRATE to Androidx? my dependencies (including firebase) already have androidx references and they are breaking my app?

mikehardy commented 5 years ago

@FrankGoortani sure there’s a way -> do not upgrade those libraries. If you upgrade to the newest firebase libraries for instance, you must move to AndroidX. So don’t do that. Use the versions immediately prior to the upgrade. Similarly, for any other libraries that have started converting their dependencies to AndroidX, do not bump those versions.

laurent22 commented 5 years ago

@FrankGoortani, I think you have two options:

laurent22 commented 5 years ago

@mikehardy, I think the issue is mainly for people who use react-native-notification. Even if they don't explicitly upgrade to AndroidX, rn-notification is going to use the latest Firebase. So a solution is to lock the dependencies as mentioned in the Stackoverflow answer.

mikehardy commented 5 years ago

This is an error in the library and should be fixed with a pull request that allows you to specify a version in your app/build.bradle ext block: https://github.com/wix/react-native-notifications/blob/master/android/build.gradle#L24 - example https://github.com/react-native-community/react-native-camera/blob/master/android/build.gradle#L78

JofBigHealth commented 5 years ago

We've had some success doing the following on RN 0.59.x

Switch android/app/build.gradle to use androidx

E.g. using the migration table here to convert the legacy build artefacts to the AndroidX equivalents

-   implementation 'com.android.support:appcompat-v7:27.1.1'
-   implementation 'com.android.support:support-v4:27.1.1'
-   implementation 'com.android.support:support-media-compat:27.1.1'
-   implementation 'com.android.support:multidex:1.0.3'

+   implementation 'androidx.appcompat:appcompat:1.0.2'
+   implementation 'androidx.legacy:legacy-support-v4:1.0.0'
+   implementation 'androidx.media:media:1.0.1'
+   implementation 'androidx.multidex:multidex:2.0.1'

Change 1st party code to use AndroidX

E.g.

- import android.support.v7.app.AppCompatActivity;
- import android.support.annotation.Nullable;

+ import androidx.appcompat.app.AppCompatActivity;
+ import androidx.annotation.Nullable;

(Maybe not needed) Patch gradle.properties to turn off androidx for those that don't support it

A postinstall that adds

android.useAndroidX=false
android.enableJetifier=false

To all relevant instances of

${rootDir}/node_modules/some-react-native-project/android/gradle.properties

We did this for react-native-fast-image prior to discovering jetifier so it may not be necessary.

Run jetifier/jetifire as part of postinstall

yarn add jetifier --dev
npx jestify

Hopefully that helps someone even if it might be slightly off topic.

FrankGoortani commented 5 years ago

Thanks @laurent22 and @mikehardy for your response! I'm trying them now. FYI, my problem has been with @react-native-community/netinfo

mikehardy commented 5 years ago

@JofBigHealth I think you are getting lucky with the combination of jetifier and your postinstall de-jetifier of projects. If those projects bundle libs the standard (gradle plugin) jetifier won’t transform them, but the npm source jetifier will have transformed their source code. If you test it and it works okay, but seems iffy to me. Did you add that “remove jetifier from react-native modules gradle” step in response to something specific? An actual library you could point to that I could add to https://github.com/mikehardy/rn-androidx-demo/blob/master/make-demo.sh

JofBigHealth commented 5 years ago

@mikehardy Thanks for the script - very clear example. Interesting to see so many people manipulating code with sed and postinstall. I don't have time to produce something similar right now but I'll see if I can fit it in towards the end of the week using the third party libs we use in our project.

Did you add that “remove jetifier from react-native modules gradle” step in response to something specific?

The gradle.properties patch might not be required; it was a step I wrote prior to running jetifier in order to get react-native-fast-image working and I've not subsequently tested it without that change. I'll update my comment to reflect the uncertainty.

mikehardy commented 5 years ago

Some new learning in combination with react-native 0.60. I no longer see failures with AndroidX + jetifier + RN0.59. But with AndroidX + jetifier + RN0.60 I see errors sometimes, like this one with react-native-maps: https://github.com/react-native-community/react-native-maps/pull/2927

Some packages that directly depend on the appcompat support libraries will need to have the whole library name overridden in android/build.gradle ext{} / safeExtGet{} style apparently. That can be patch-packaged and libraries can be patched, but that’s unexpected. Not sure what to do about that, but I think I can get RN0.60 working with about any non-migrated libraries now at least, with that style.

mikehardy commented 5 years ago

Library / module maintainers: It just occurred to me that you should update your issue templates to ask if the app has converted to AndroidX in the android issue section. @kelset can that go in the .github stuff? I know nothing of that

FrankGoortani commented 5 years ago

@laurent22 , @mikehardy Thanks again. With locking the versions and checking the Androidx references, I managed to bring my app up again!

Run this inside android folder and there should be no result: ./gradlew :app:dependencies|grep androidx inside gradle.properties:

googlePlayServicesVersion=16.1.0
firebaseVersion=17.6.0
android.useAndroidX=false
android.enableJetifier=false
khat33b commented 5 years ago

For people facing library "libjsc.so" not found error, the solution is in this link.

Add the following code in your app/build.gradle:

// On top of the file before the android block
def useIntlJsc = false
// inside dependencies block
 if (useIntlJsc) {
        implementation 'org.webkit:android-jsc-intl:+'
    } else {
        implementation 'org.webkit:android-jsc:+'
    }
mikehardy commented 5 years ago

@matt-oakes @kelset I think this might be close-able?

Jetifier just took a pull request that results in sub-second times for most normal projects and we haven't seen a demonstrated failure in a few days. It has a nice test suite matrix for all supported node versions and linux and macos at least (sorry windows, but we do know it works there)

I'm using it in reverse mode on a work project even :-), and it is documented for common user and maintainer problems, with an active partner (@m4tt72) that has github and npm access and 2 backups (which is good, because I'm going to go on vacation for most of July)

The general plan is:

Further instructions for minority-usage are for people that stay on RN0.59 but their libraries start moving:

:crossed_fingers:

matt-oakes commented 5 years ago

Agreed. Closing this now 👍

kelset commented 5 years ago

Perfect, thanks for the help everyone!

WebMobi59 commented 5 years ago

I've failed to build react native project after migrating to AndroidX. I followed the @mikehardy 's guide.

image

Here is my package.json file.

{
  "name": "ujama",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "flow": "flow; test $? -eq 0 -o $? -eq 2",
    "lint": "eslint"
  },
  "standard": {
    "parser": "babel-eslint"
  },
  "dependencies": {
    "@babel/core": "^7.5.4",
    "@babel/plugin-proposal-decorators": "^7.3.0",
    "@babel/plugin-proposal-function-bind": "^7.2.0",
    "@babel/runtime": "^7.5.4",
    "@expo/ex-navigation": "git+https://github.com/hmolotsi/ex-navigation",
    "@react-native-community/netinfo": "^1.4.0",
    "@ungap/url-search-params": "ungap/url-search-params",
    "babel-plugin-transform-flow-strip-types": "^6.22.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "buffer": "^5.2.1",
    "email-validator": "^1.1.1",
    "flow-bin": "^0.48.0",
    "jetifier": "^1.6.3",
    "lodash": "^4.17.11",
    "lottie-react-native": "^3.0.4",
    "moment": "^2.24.0",
    "native-base": "^2.12.1",
    "parse-address-string": "^0.0.3",
    "prop-types": "^15.6.0",
    "pubnub": "4.20.1",
    "query-string": "^6.1.0",
    "react": "16.8.6",
    "react-addons-create-fragment": "^15.6.2",
    "react-native": "^0.60.3",
    "react-native-alphabetlistview": "git+https://github.com/i6mi6/react-native-alphabetlistview",
    "react-native-autocomplete-input": "3.5.0",
    "react-native-background-fetch": "2.5.4",
    "react-native-boundary": "^1.0.5",
    "react-native-button": "^2.3.0",
    "react-native-cached-image": "1.4.3",
    "react-native-calendar-events": "git+https://github.com/samratshekhar/react-native-calendar-events",
    "react-native-calendars": "^1.17.2",
    "react-native-camera": "^3.0.0",
    "react-native-communications": "2.2.1",
    "react-native-contacts": "4.0.2",
    "react-native-country-picker-modal": "^0.7.1",
    "react-native-credit-card-input": "^0.4.1",
    "react-native-device-info": "^0.16.0",
    "react-native-fast-image": "^5.2.0",
    "react-native-fbsdk": "^0.8.0",
    "react-native-firebase": "4.3.8",
    "react-native-form": "^2.1.2",
    "react-native-geocoding": "0.2.0",
    "react-native-gifted-chat": "0.3.0",
    "react-native-google-places-autocomplete": "^1.3.9",
    "react-native-google-signin": "^1.2.1",
    "react-native-hyperlinked-text": "^1.0.2",
    "react-native-image-crop-picker": "0.24.1",
    "react-native-image-fit": "^0.9.10",
    "react-native-image-view": "^2.1.4",
    "react-native-image-zoom-viewer": "^2.2.25",
    "react-native-loading-spinner-overlay": "^0.5.2",
    "react-native-maps": "0.25.0",
    "react-native-material-ui": "^1.22.0",
    "react-native-mauron85-background-geolocation": "^0.5.2",
    "react-native-modal": "^5.1.0",
    "react-native-modal-datetime-picker": "5.1.0",
    "react-native-pathjs-charts": "0.0.34",
    "react-native-photo-browser": "git+https://github.com/hmolotsi/react-native-photo-browser",
    "react-native-progress": "^3.4.0",
    "react-native-prompt-android": "^0.3.3",
    "react-native-qrcode-scanner": "^1.0.1",
    "react-native-qrcode-svg": "^5.1.1",
    "react-native-rate": "^1.0.9",
    "react-native-shared-preferences": "1.0.0",
    "react-native-sms": "^1.5.2",
    "react-native-snap-carousel": "3.8.0",
    "react-native-swipeout": "^2.3.3",
    "react-native-tableview-simple": "git+https://github.com/Hanumanthraya/react-native-tableview-simple",
    "react-native-vector-icons": "^6.4.1",
    "react-native-webview": "^5.8.1",
    "react-redux": "^5.0.7",
    "realm": "^2.24.0",
    "redux": "^3.7.2",
    "redux-actions": "^2.2.1",
    "rn-fetch-blob": "^0.10.15",
    "sendbird": "3.0.97",
    "utf8": "^3.0.0"
  },
  "devDependencies": {
    "@babel/plugin-proposal-function-bind": "^7.2.0",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-eslint": "^7.1.1",
    "babel-jest": "^24.8.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-react-native": "^1.9.1",
    "eslint": "^6.0.1",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^3.0.2",
    "eslint-plugin-react": "~6.9.0",
    "eslint-plugin-react-native": "3.1.0",
    "jest": "^24.8.0",
    "jest-react-native": "^18.0.0",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-test-renderer": "16.8.6"
  }
}

Here is what I did.

  1. Migrate to AndroidX via Android Studio 3.4.2
  2. npx jetify
  3. react-native run-android

How can I migrate to AndroidX successfully?

rezasazesh commented 5 years ago

@WebMobi59 looking at the error, do you have the following code inside android/app/build.gradle?

either

android {
  ...
  defaultConfig {
    ...
    missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line
  }
}

OR

android {
  ...
  defaultConfig {
    ...
    missingDimensionStrategy 'react-native-camera', 'mlkit' <-- insert this line
  }
}

looks like the 'general' or 'mlkit' is not specified for react-native-camera