I have next grade
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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.google.android.material:material:1.0.0-rc01'
}
But when I want to build app I get next log:
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
Okey! Go to manifest and do it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.chopcode.myapplication">
<application
tools:replace="android:appComponentFactory"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
</application>
</manifest>
Then I get this error in my Logcat:
Manifest merger failed with multiple errors, see logs that I have Linked with it
Reason of Fail
You are using material library which is part of AndroidX. If you are not aware of AndroidX, please go through this answer.
For example -
In your gradle, you are using
com.android.support:appcompat-v7
(Part of old --Android Support Library--)com.google.android.material:material
(Part of AndroidX) (AndroidX build artifact ofcom.android.support:design
)Solution
So the solution is to use either AndroidX or old Support Library. I recommend to use AndroidX, because Android will not update support libraries after version 28.0.0. See release notes of Support Library.
Just migrate to AndroidX.Here is my detailed answer to migrate to AndroidX. I am putting here the needful steps from that answer.
Before you migrate, it is strongly recommended to backup your project.
Put these flags in your
gradle.properties
Check @Library mappings for equal AndroidX package.
Check @Official page of Migrate to AndroidX
What is Jetifier?
1.Added these codes to at the end of your app/build.gradle:
2.Modified sdk and tools version to 28:
3.In your AndroidManifest.xml file, you should add two line:
Or Simply
I'm also facing the same issue, for your android studio, you just change the android Gradle plugin version 3.3.2 and Gradle version is 5.1.1
Please go to Refactor->Migrate->Migrate to Android X.
Please add this to your gradle.properties file: android.enableJetifier=true android.useAndroidX=true
And perform Sync.
In my case, this is working perfectly.. I have added below two line codes inside manifest file
Credit goes to this answer.