Manifest merger failed : Attribute application@appComponentFactory - Androidx
After hours of struggling, I solved it by including the following within app/build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Changes in build.gradle:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
Refer to: https://developer.android.com/jetpack/androidx/migrate
ERROR: Manifest merger failed : Attribute application@appComponentFactory
Find a solution by adding googlePlayServicesVersion = "16.+"
to app/build.gradle
, since Google Services has been updated :
buildscript {
ext {
...
googlePlayServicesVersion = "16.+"
}
...
}
Manifest merger failed : Attribute application@appComponentFactory cant solve this
You are using
implementation 'com.google.firebase:firebase-messaging:19.0.1'
Firebase migrated to AndroidX in the latest release.
It means that you are using both, support libraries and androidx libraries.
You can:
- migrate to androidx as described below
- downgrade your firebase dependencies (but it is not a real solution because you have to migrate sooner or later)
You can check the official release notes:
Warning: This release is a MAJOR version update and breaking change.
The latest update to Google Play services and Firebase includes the following changes:
Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:
- Upgrade
com.android.tools.build:gradle
to v3.2.1 or later. - Upgrade
compileSdkVersion
to 28 or later. - Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
After defining ButterKnife , Manifest merger failed : Attribute application@appComponentFactory error
You cannot use butterknife:10.x.x unless you also migrated to AndroidX. If you haven't migrated, you'll need to stick to 9.0.0 for now. Once you migrate, then you can update to 10.1.0 (or whatever is latest at that time). –
Manifest merger failed : Attribute application@appComponentFactory after add Exoplayer 2.10.5
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.1] AndroidManifest.xml:22:18-86
value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:25:5-171:19 to override.
My Suggestion is - Move to AndroidX
. You can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
Upgrade to
classpath 'com.android.tools.build:gradle:3.6.1'//3.6.3
Your dependencies
will
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Related Topics
Updating Android UI Using Threads
Android Failed to Start Emulator:Cannot Run Program
Android: How to Periodically Send Location to a Server
Gradle - Library Duplicates in Dependencies
How to Create Edittext Accepts Alphabets Only in Android
Audiorecord Object Not Initializing
Android Bitmap to Base64 String
Unsupported Major.Minor Version 52.0 When Rendering in Android Studio
Share Sqlite Database Between 2 Android Apps
How to Start an Activity from a Service
How to Get Higher Precision of "Cpu%" Than That from Top Command
Android Command Line Tools Sdkmanager Always Shows: Warning: Could Not Create Settings
Loading Existing .HTML File with Android Webview
Android: Activity Getting Destroyed After Calling Camera Intent
Get Android API Level of Phone Currently Running My Application