Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Android Studio is forcing to use Androidx from Android support library?

Working on a React Native project but out of sudden it stopped working & started giving an error:

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 AndroidManifest.xml:7:5-117 to override.

I know Google has done with Support Library class after 28 and I know How to migrate whole project from Support Library class to AndroidX class.

My question is:

  • Is there any possible way to keep using Support Library class rather than shifting to AndroidX class?

  • How to fix this issue?

like image 907
Mohsin Avatar asked Jun 18 '19 08:06

Mohsin


People also ask

What is the difference between AndroidX and Android support?

AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. androidx packages fully replace the Support Library by providing feature parity and new libraries.

Why should I migrate to AndroidX?

Why you should migrate your app to AndroidX? Unlike the Support Library, AndroidX packages are separately maintained and updated. The androidx packages use strict Semantic Versioning . So you can update AndroidX libraries in your project independently.

Should I use legacy Android support libraries?

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well. So all Android apps should now aim to use AndroidX, instead of the old support library.


Video Answer


2 Answers

You can lock down your googleservices and firebase versions to avoid androidX.

In android/build.gradle add:

buildscript {
  ...
  ext {
    // Lock down googlePlayServicesVersion
    googlePlayServicesVersion = "16.1.0"
    firebaseVersion = "17.6.0"
  }
}

OR in gradle.properties add:

googlePlayServicesVersion=16.1.0
firebaseVersion=17.6.0
like image 95
A-J-A Avatar answered Oct 23 '22 01:10

A-J-A


Probably post your app level gradle file here. Ideally if you are using some other dependency which is the updated/latest one then you would get this error.

If any of the dependency is the latest/updated one please downgrade it to the lesser version from checking the change logs from it's github. For me the culprit was stripe version which was internally using the androidx and was getting this error. i downgraded it and boom! It's gone :)

And also disable the androidx from gradle.properties file using

android.useAndroidX=false
android.enableJetifier=false

Which forces the androidx to be disabled.

like image 42
pramod_m Avatar answered Oct 23 '22 01:10

pramod_m