YosiFZ
YosiFZ

Reputation: 7900

Android add AndroidX library to non-androix project

I have an Android Application and i want to add this library:

implementation 'com.google.android.ump:user-messaging-platform:1.0.0'

When I add it I get this 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:23:5-209:19 to override.

When I add this line:

tools:replace="android:appComponentFactory"

I get this error:

Error:
tools:replace specified at line:23 for attribute android:appComponentFactory, but no new value specified

Any idea what is the problem? How I can add this library? Maybe I can add a previous version of this library?

From what I read it's related to AndroidX, But I don't want to update my project to AndroidX because it's an old project and this will cause me a lot of problems.

EDIT

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:28.0.0'
compile 'com.android.support:recyclerview-v7:28.0.0'
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support:cardview-v7:28.0.0'
implementation "com.android.support:support-compat:28.0.0"
compile 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.ump:user-messaging-platform:1.0.0'

Upvotes: 2

Views: 180

Answers (2)

Martin Zeitler
Martin Zeitler

Reputation: 76639

Just enable to Jetifier to have the other dependencies name-space translated:

android.useAndroidX=true
android.enableJetifier=true

Upvotes: 1

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

Error: tools:replace specified at line:23 for attribute android:appComponentFactory, but no new value specified

You should add both

 tools:replace="android:appComponentFactory"
 android:appComponentFactory="android.support.v4.app.CoreComponentFactory"

Make sure, You added below in your gradle.properties file

  android.useAndroidX=true
  android.enableJetifier=true

FYI

implementation 'com.google.android.ump:user-messaging-platform:1.0.0'

We recommend updating your project to use the final version of the support library: version 28.0.0. This is because AndroidX artifacts with version 1.0.0 are binary equivalent to the Support Library 28.0.0 artifacts.

Upvotes: 1

Related Questions