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 Google Play services
A quick solution to your problem could be to add the following 3 lines in your AndroidMannifest.xml
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="@string/app_name"
So, after adding the above 3 lines your AndroidMannifest.xml should look like,
AndroidMannifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<!--Add the following 3 lines-->
<application
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="@string/app_name"
...
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
EDIT: Update your dependencies to the latest version as play-services-ads is using androidx version of support library and you are using the traditional one.
build.gradle (Module: app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout: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.google.android.gms:play-services-ads:18.2.0'
}
I hope it will fix your build error. Let me know if it works?
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.
Manifest merger failed : Attribute application@appComponentFactory...Android Studio 3.2
Its because your project has different versions of the same library - androidx and pre-androidx.
In android studio tool bar go to: Refactor-> Migrate to androidX... -> Migrate
Manifest merger failed : Attribute application@appComponentFactory (android.support.v4.app.CoreComponentFactory)
The issue is happening because some of your libraries are using androidx
components, please try to use a lower version, and make sure that you don't put +
while adding dependencies
Related Topics
Transitive Dependencies for Local Aar Library
Android - Local Image in Webview
Android Get Image from Gallery into Imageview
Sqliteopenhelper Problem with Fully Qualified Db Path Name
Remove Listview Items in Android
How to Request Permissions from a Service in Android Marshmallow
How to Create Edittext Accepts Alphabets Only in Android
How to Display Album Art Using Mediastore.Audio.Albums.Album_Art
Detecting Whether a Headset Is Plugged into an Android Device or Not
Adt Will Not Allow Creation of Android Activity
Java.Lang.Classnotfoundexception on Working App
Convert Content:// Uri to Actual Path in Android 4.4
How to Capture Soft Keyboard Input in a View
How to Prevent System Font-Size Changing Effects to Android Application
Difference Between Oncreateview and Onviewcreated in Fragment