Manifest merger failed : Attribute application@appComponentFactory - Androidx
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
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
Reason of this error-
Because after upgrade, androidx.core:core
is accessed somewhere, when your project is still not using androidx. So classes like CoreComponentFactory
and many others are now found at two places - androidx.core:core
and com.android.support:support-compat
. That's why this error occured.
What is solution?
You should migrate to AndroidX. If you don't know about AndroidX. Please read What is AndroidX?
How to migrate your project
After Android Studio 3.2 (September 2018), there is direct option to migrate existing project to AndroidX
. This refract all packages automatically.
Before you migrate, it is strongly recommended to backup your project.
Existing project
- Android Studio > Refactor Menu > Migrate to AndroidX...
- It will analysis and will open Refractor window in bottom. Accept changes to be done.
New project
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Check @Library mappings for equal AndroidX package.
Check @Official page of Migrate to AndroidX