title: Change to androidX in react-native
body: <p>I'm trying to change my <code>react-native</code> project to <code>androidx</code>.
  I want to do it because I got this error suddenly when trying to run my project:</p>
  
  <pre><code>com.android.build.api.transform.TransformException: Error while generating the main dex list.
  </code></pre>
  
  <p>I was reading some posts about the issue and I tried to add those lines:</p>
  
  <pre><code>android.useAndroidX=true
  android.enableJetifier=true
  </code></pre>
  
  <p>because when I used stack trace I was getting this error:</p>
  
  <pre><code>Program type already present: androidx.versionedparcelable.CustomVersionedParcelable react native
  </code></pre>
  
  <p>I added this lines to my <code>local.propeties</code> file but when I did that I have seen that I need to change all my <code>node-module</code> files to use <code>androidx</code></p>
  
  <p>In addition I was trying to update the package <code>react-native-device-info</code> to the newest version 2.1.2 but still the same result...</p>
  
  <p>my react native version:</p>
  
  <pre><code>react-native-cli: 2.0.1
  react-native: 0.50.4
  </code></pre>
  
  <p>I'm attaching my files:</p>
  
  <p><strong>app/build.gradle:</strong></p>
  
  <pre><code>apply plugin: "com.android.application"
  
   buildscript {
     repositories {
       maven { url 'https://maven.fabric.io/public' }
     }
     dependencies {
       // The Fabric Gradle plugin uses an open ended version to react
       // quickly to Android tooling updates
       classpath 'io.fabric.tools:gradle:1.+'
     }
   }
   apply plugin: 'io.fabric'
   repositories {
     maven { url 'https://maven.fabric.io/public' }
   }
  import com.android.build.OutputFile
  
  project.ext.react = [
      entryFile: "index.js"
  ]
  
  apply from: "../../node_modules/react-native/react.gradle"
  
  
  def enableSeparateBuildPerCPUArchitecture = false
  
  def enableProguardInReleaseBuilds = false
  
  android {
      compileSdkVersion 28
      buildToolsVersion "28.0.3"
      dexOptions {
              javaMaxHeapSize "4g"
          }
      defaultConfig {
          applicationId "com.x"
          minSdkVersion 19
          targetSdkVersion 26
          versionCode 14
          versionName "2.3.0"
          multiDexEnabled true
          ndk {
              abiFilters "armeabi-v7a", "x86"
          }
      }
      signingConfigs {
          release {
              if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                  storeFile file(MYAPP_RELEASE_STORE_FILE)
                  storePassword MYAPP_RELEASE_STORE_PASSWORD
                  keyAlias MYAPP_RELEASE_KEY_ALIAS
                  keyPassword MYAPP_RELEASE_KEY_PASSWORD
              }
          }
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include "armeabi-v7a", "x86"
          }
      }
      buildTypes {
          release {
              signingConfig signingConfigs.release
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
          }
      }
      // applicationVariants are e.g. debug, release
      applicationVariants.all { variant -&gt;
          variant.outputs.each { output -&gt;
              // For each separate APK per architecture, set a unique version code as described here:
              // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
              def versionCodes = ["armeabi-v7a":1, "x86":2]
              def abi = output.getFilter(OutputFile.ABI)
              if (abi != null) {  // null for the universal-debug, universal-release variants
                  output.versionCodeOverride =
                          versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
              }
          }
      }
  }
  
  dependencies {
      compile project(':react-native-orientation')
      compile project(':react-native-device-information')
      compile project(':react-native-ble-manager')
      compile project(':react-native-fabric')
      compile project(':react-native-vector-icons')
      compile project(':react-native-spinkit')
      compile project(':react-native-push-notification')
      compile project(':react-native-picker')
      compile project(':react-native-linear-gradient')
      compile project(':react-native-image-crop-picker')
      compile project(':react-native-firebase')
      compile project(':react-native-fcm')
      compile project(':react-native-config')
      implementation project(':react-native-picker')
      implementation project(':react-native-device-info')
      implementation project(':react-native-fcm')
      implementation project(':react-native-firebase')
      implementation project(':react-native-svg')
      implementation project(':react-native-vector-icons')
      implementation project(':react-native-spinkit')
      implementation project(':react-native-push-notification')
      implementation project(':react-native-linear-gradient')
      implementation project(':react-native-image-crop-picker')
      implementation project(':react-native-config')
      implementation project(':react-native-picker-module')
      implementation fileTree(dir: "libs", include: ["*.jar"])
      implementation "com.google.android.gms:play-services-gcm:15.0.1"
      implementation "com.android.support:appcompat-v7:28.0.0-rc02"
      implementation "com.facebook.react:react-native:+"  // From node_modules
      implementation 'com.google.firebase:firebase-core:16.0.1'
      implementation 'com.google.firebase:firebase-messaging:17.0.0' //17.3.1
      implementation 'com.android.support:multidex:1.0.3'
      //implementation 'com.google.firebase:firebase-notifications'
      compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
           transitive = true;
      }
  
  }
  
  // Run this once to be able to run the application with BUCK
  // puts all compile dependencies into folder libs for BUCK to use
  task copyDownloadableDepsToLibs(type: Copy) {
      from configurations.compile
      into 'libs'
  }
  apply plugin: 'com.google.gms.google-services'
  com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
  </code></pre>
  
  <p><strong>android/build.gradle</strong></p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          google()
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.2.1'
          classpath 'com.google.gms:google-services:4.1.0'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  //com.android.ddmlib.DdmPreferences.setTimeOut(50000)
  
  allprojects {
      repositories {
                  // Add jitpack repository (added by react-native-spinkit)
                  maven { url "https://jitpack.io" }
          mavenLocal()
          google()
          jcenter()
          // maven{
          //     url 'https://maven.google.com'
          // }
          maven {
              // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
              url "$rootDir/../node_modules/react-native/android"
          }
  
      }
  }
  
  ext {
    compileSdkVersion = 28
    targetSdkVersion = 28
    buildToolsVersion = "28.0.3"
    supportLibVersion = "28.0.0-rc02"
    googlePlayServicesVersion = "15.0.1"
    oreoEXPERIMENTAL = "yes"
  }
  
  subprojects {
      afterEvaluate {project -&gt;
          if (project.hasProperty("android")) {
              android {
                  compileSdkVersion 28
                  buildToolsVersion '28.0.3'
              }
          }
      }
  }
  
  
  </code></pre>
  
  <p>my application for <strong>androidManifest.xml</strong>:</p>
  
  <pre><code>  &lt;application
        android:name=".MainApplication"
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/AppTheme"
        tools:replace="android:appComponentFactory"
        android:appComponentFactory="whateverString"
  &gt;
  </code></pre>
  
  <p>Is there anyway to fix this issue for now? I can't run my project suddenly</p>