DEV Community

Bartmr
Bartmr

Posted on

Not being able to run a React Native or Cordova project after 17th of July, because of AndroidX and Google Play Services

After the 17th of July update to the Google Play Services, some of you who've cleaned up your React Native Android project before a build, might have encountered an error similar to this

Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:52:5-309:19 to override.
Enter fullscreen mode Exit fullscreen mode

For normal Android applications, the solution is just migrating to AndroidX and whatever isn't using AndroidX, Gradle deals with converting the import statements on build time by using Jetifier. But Gradle's Jetifier only works on already packaged Android modules. It doesn't work on native React Native modules that bring their full native source code projects intact, and are compiled when you start your React Native app.

For those cases, the solution is:

  1. Install this package and follow its instructions. If your project still doesn't start after that, follow the extra steps below...
  2. Go to your android/app/build.gradle file, and exchange all dependencies that are inside the Arctifact Mappings section in the AndroidX Migration guide with the new AndroidX build artifact paths.
  3. Go to your own native code inside android/app/src and do the same with the import statements refering to the Old build artifacts
  4. Run your app again.
  5. Comment this post :D

Good luck. BTW, first article here on DEV.TO

Top comments (0)