Tutorial: How to Fix a Failing Android Build Due to [androidx.core:core:1.0.0] Issues (June 2019)
Tags: androidstudio, android, reactnative, mobileappdevelopment
Published: 2019-06-19 03:07:40

---
title: Tutorial: How to Fix a Failing Android Build Due to [androidx.core:core:1.0.0] Issues (June 2019)
published: true
tags: android-studio,android,react-native,mobile-app-development
canonical_url: https://medium.com/@jrapala/tutorial-how-to-fix-a-failing-android-build-due-to-androidx-core-core-1-0-0-issues-june-2019-cbfb5d94de27
---

![](https://cdn-images-1.medium.com/max/1024/1*LR5N28VEu0_KgRNsyj_qAw.jpeg)<figcaption>Photo by <a href="https://www.instagram.com/johnnywharris/">Johnny Wharris</a></figcaption>

If you’re a React Native developer like me, you may have been surprised to see your Android build that JUST WORKED, failing and failing and failing again.

The issue, if you’re in Android Studio, went something like this:

```
Caused by: java.lang.RuntimeException: Manifest merger failed : 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 manifestMerger6369655802117611865.xml:7:5–9:19 to override.
```

Did you think to yourself _“Huh? AndroidX? I’m not supporting that yet.”_, then follow along. Here’s how to fix the issue without adding AndroidX support.

### What Happened?

Google pulled a fast one on us yesterday (June 17, 2019) and released a [MAJOR version update](https://developers.google.com/android/guides/releases) on it’s `Google Play` and `Firebase` libraries. That means, any dependencies imported to the tune of:

```groovy
implementation ‘com.google.android.gms:play-services-base:+’
```

…(note the `+`) will be affected.

### How to Fix It

1) Hop over to your `/android/app/build.gradle` file and check out your dependencies. Search for any instance of `play-services` or `firebase`* and see if it’s pulling in the latest version (`+`).

```groovy
dependencies {
  implementation "com.android.support:appcompat-v7...
  implementation "com.facebook.react:react-native:+"
  // found one! vv
  implementation "com.google.android.gms:play-services-base:+"
  // found one! vv
  implementation "com.google.android.gms:play-services-maps:+"
  implementation "com.google.firebase:firebase-core:16.0.1"
}
```

2) Head over to [MVNRepository](https://mvnrepository.com/) and search for the troublesome dependencies. Here you’ll be able to find the last released version of your module. Update `/android/app/build.gradle` to that version along with a force flag to handle any version conflicts:

```groovy
dependencies {
 implementation "com.android.support:appcompat-v7..
 implementation "com.facebook.react:react-native:+"
 implementation ("com.google.android.gms:play-services-base:16.1.0"){ force = true }
 implementation ("com.google.android.gms:play-services-maps:16.1.0"){ force = true }
 implementation "com.google.firebase:firebase-core:16.0.1"
}
```

3) Time to handle your `node_modules`. Navigate into `/android` and run the following command:

```shell
./gradlew :app:dependencies
```

This will generate a dependency tree for your entire project.

4) Grab the tree and paste in into a text editor. Search for any instance of `play-services` or `firebase`* and navigate up the tree to see where the module is being used. In this case, `react-native-push-notifications` has a `com.google.android.gms:play-services-gcm:+` dependency.

```shell
+ — — project :react-native-push-notification
 | + — — com.android.support:appcompat-v7:28.0.0 (\*)
 | + — — com.facebook.react:react-native:+ -\> 0.59.8 (\*)
 | + — — com.google.android.gms:play-services-gcm:+ -\> 17.0.0 (\*)
 | + — — me.leolin:ShortcutBadger:1.1.8
```

5) Patch those packages! If I am in a time crunch, I will use [`patch-package`](https://github.com/ds300/patch-package), a genius library that lets you make changes to a package and then creates a patch for you to store with your project. The patch will then apply via a `postinstall` any time you or someone on your team runs `npm i`.

In my case, I navigated to the `build.gradle` file of `react-native-push-notification`, made my updates, ran:

```shell
npx patch-package react-native-push-notification
```

…and voila! I have a patch!

#### And You’re Done!

In my case, I needed to apply patches to both `react-native-push-notification` and `react-native-push-notification`.

Do note that this is just a band-aid until you’re ready to support AndroidX and all its glory 🤖

Hope this helps!

*For a full list of updated dependencies navigate [here](https://developers.google.com/android/guides/releases).

---

👋 Hi! I’m [Juliette](http://www.julietterapala.com). I work at [Eventric](https://www.eventric.com/) as a Software Developer. Come follow me on Twitter at [@Juliette](https://twitter.com/JulietteR).