We would like to use the most current material design ui elements presented by Google. Therefore I added com.google.android.material:material:1.0.0-beta01
in our projects gradle file. But since then I get the following error.
Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0-beta01] AndroidManifest.xml:22:18-86 is also present at [com.android.support:support-compat:28.0.0-beta01] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:5:5-40:19 to override.
Without the material library everything works fine.
What I already tried
tools:replace="android:appComponentFactory"
to our Manifest file as suggested in the error message. But this left me with a new error message:java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:524) at com.android.build.gradle.tasks.ProcessManifest.doFullTaskAction(ProcessManifest.java:75) at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
I checked the log file but the only warning shown in idea.log is
2018-08-08 11:08:21,500 [thread 267] WARN - .tools.idea.model.ManifestInfo - getMergedManifest failed Manifest merger failed with multiple errors, see logs 2018-08-08 11:08:21,642 [thread 267] WARN - .tools.idea.model.ManifestInfo - getMergedManifest failed Manifest merger failed with multiple errors, see logs 2018-08-08 11:08:21,917 [J pool 0/7]
More information
API Version
android {
compileSdkVersion 28
buildToolsVersion '28.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
(the same API is chosen in file > project structure in Android Studio)
Dependencies:
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
/** ANDROID LIBRARIES **/
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
api 'com.android.support:support-v13:28.0.0-beta01'
api 'com.google.android.material:material:1.0.0-beta01'
api 'com.android.support:design:28.0.0-beta01'
api 'com.android.support:preference-v7:28.0.0-beta01'
api 'com.android.support:cardview-v7:28.0.0-beta01'
api 'com.android.support:customtabs:28.0.0-beta01'
api 'com.android.support:support-v4:28.0.0-beta01'
/** GOOGLE PLAY SERVICE **/
api 'com.google.android.gms:play-services-auth:15.0.1'
api 'com.google.android.gms:play-services-drive:15.0.1'
api 'com.google.android.gms:play-services-fitness:15.0.1'
api 'com.google.android.gms:play-services-maps:15.0.1'
api 'com.google.android.gms:play-services-wearable:15.0.1'
api 'com.google.android.gms:play-services-vision:15.0.2'
api 'com.google.firebase:firebase-core:16.0.1'
api 'com.google.firebase:firebase-perf:16.0.0'
api 'com.crashlytics.sdk.android:crashlytics:2.9.4'
//sunrise and sundown calculation for map day and night mode
api 'com.luckycatlabs:SunriseSunsetCalculator:1.2'
/** GOOGLE MAPS **/
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.google.code.gson:gson:2.8.0'
/** EXTERNAL LIBRARIES **/
implementation 'org.osmdroid:osmdroid-android:5.6.5'
implementation 'org.osmdroid:osmdroid-mapsforge:5.6.5'
implementation 'org.mapsforge:mapsforge-map-android:0.6.1'
implementation 'org.mapsforge:mapsforge-map:0.6.1'
implementation 'com.caverock:androidsvg:1.2.2-beta-1'
//dropbox api
implementation 'com.dropbox.core:dropbox-core-sdk:3.0.6'
androidTestImplementation 'junit:junit:4.12'
implementation files('libs/samsung-health-data-v1.3.0.jar')}
Manifest
<manifest
package="com.user.libraries.bluetooth"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
tools:replace="android:appComponentFactory"
android:allowBackup="true"
android:supportsRtl="true">
<service android:name="com.user.libraries.location.LocationService" />
<service android:name="com.user.libraries.location.BleLocationTrackerService" />
<service android:name="com.user.libraries.sensors.SensorService"/>
<service android:name="com.user.libraries.sharing.DataExchangerService"/>
<receiver
android:name="com.user.libraries.bluetooth.BluetoothStateReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
Any idea how I can solve this issue?
Try adding the following labels to resolve the issue: Add the xmlns:tools line in the manifest tag. Add tools:replace= or tools:ignore= in the application tag.
If two manifests have the same XML element, then the tool merges the two elements together using one of three merge policies: Merge. Combine all non-conflicting attributes into the same tag and merge child elements according to their respective merging policy.
The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
Don't forget to add
android.useAndroidX=true
android.enableJetifier=true
to your gradle.properties. I always forget this when I get on a new machine because gradle.properties is not in source control. Would be great if we got a sensible error in this case.
Main problem here is that you are adding
com.google.android.material:material:1.0.0-beta01
that belongs to newly released androidx package and nowadays it is not compatible with android support library that you have in your dependencies.
You have 2 options:
Here is sample of working code:
<android.support.design.widget.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:boxStrokeColor="@color/colorAccent"
app:boxStrokeWidth="5dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/messageEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With