问题
My application was working fine before but recently after android pie update I have changed the targetSDKVersion to 28 and added material design support and got 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 element at AndroidManifest.xml:7:5-53:19 to override.
I have updated all the libraries and tried all the suggestions that it gave me but still, I cannot figure out the program. Below are the dependencies that I have added.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation group: 'com.android.support', name: 'customtabs', version: '28.0.0'
}
回答1:
it says your support
dependency has conflict with androidx.core
dependency
the android studio cannot use android x
dependencies with previous support
dependencies at the same time. you should just use one of them.
use these dependencies
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
use this link to refactor your dependencies https://developer.android.com/topic/libraries/support-library/refactor
回答2:
My error is solved and my assumption is that in order to use material design, we need to update the android studio to 3.2 because before I was using 3.1 and migrated my project to androidx. And add these two lines
android.useAndroidX=true
android.enableJetifier=true
in the gradle.properties file of the project or else you will get the error mentioned in my question.
I tried without it and found that it was because of it that I was getting the error. To upgrade the dependencies to androidx visit this site - https://developer.android.com/topic/libraries/support-library/refactor or you can do it automatically from the refractor tab of the studio.
来源:https://stackoverflow.com/questions/52566815/manifest-merger-failed-with-multiple-errors-after-adding-material-design-support