问题
i implemented 'com.stripe:stripe-android:8.5.0'
into my app gradle, and then i got the following error trying to build my project:
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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:14:5-68:19 to override.
My app gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.khoi.myApp"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.android.support:design: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.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.ncapdevi:frag-nav:3.0.0'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.20"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.crystal:crystalrangeseekbar:1.1.3'
implementation 'com.stripe:stripe-android:8.5.0'
}
apply plugin: 'com.google.gms.google-services'
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.khoi.myApp">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
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">
<activity android:name=".activities.RentActivity"
android:label="Rent">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.MainActivity"/>
</activity>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".activities.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.MainActivity"
android:theme="@style/AppTheme"></activity>
<activity
android:name=".activities.LoginActivity"
android:theme="@style/HiddenTitleTheme"></activity>
<activity
android:name=".activities.RegisterActivity"
android:theme="@style/HiddenTitleTheme">
<intent-filter>
<!-- <action android:name="android.intent.action.MAIN"/> -->
<action android:name="android.intent.action.VIEW" />
<!-- <category android:name="android.intent.category.LAUNCHER"/> -->
</intent-filter>
</activity>
</application>
</manifest>
回答1:
stripe-android
is using AndroidX and included CoreComponentFactory
class. Actually, your project already has this class, so try excluding the module from gradle which already exists or override the values in Manifest file as suggested by IDE or migrate your project to AndroidX from Refactor-> Migrate To AndroidX
.
Another solution is to use the older version of the stripe android library that doesn't use AndroidX inside.
回答2:
It's not about AndroidManifest.xml of your app.
The error message is telling that there is a collision between support-compat library 28.0.0 and other library using androidx. I doubt this stripe library is built with androidx. 'com.stripe:stripe-android:8.5.0'
You can resolve the issue by migrating your app to use androidx instead of old support libraries.
来源:https://stackoverflow.com/questions/55084013/android-manifest-merger-failed-error-after-implementing-stripe-library