Android-实施Stripe库后出现“清单合并失败”错误

时间:2019-03-10 02:52:06

标签: android android-manifest stripe-payments

我在我的应用gradle中实现了'com.stripe:stripe-android:8.5.0',然后在尝试构建我的项目时遇到以下错误:

  

清单合并失败:来自[com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91的属性application @ appComponentFactory value =(android.support.v4.app.CoreComponentFactory)       也出现在[androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value =(androidx.core.app.CoreComponentFactory)。       建议:在AndroidManifest.xml:14:5-68:19的元素上添加'tools:replace =“ android:appComponentFactory”'以进行覆盖。

我的应用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'

清单

<?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>

2 个答案:

答案 0 :(得分:1)

与您的应用程序的AndroidManifest.xml无关。

错误消息表明support-compat库28.0.0与使用androidx的其他库之间存在冲突。 我怀疑这个条纹库是用androidx构建的。 'com.stripe:stripe-android:8.5.0'

您可以通过将应用程序迁移为使用androidx而不是旧的支持库来解决此问题。

答案 1 :(得分:1)

stripe-android使用的是AndroidX,并包含CoreComponentFactory类。实际上,您的项目已经有了此类,因此请尝试从gradle中排除已存在的模块,或者按照IDE的建议覆盖Manifest文件中的值,或者将项目从Refactor-> Migrate To AndroidX迁移到AndroidX。

另一种解决方案是使用内部不使用AndroidX的条纹Android库的较早版本。