Android — ошибка «Ошибка слияния манифеста» после внедрения библиотеки Stripe

я внедрил 'com.stripe:stripe-android:8.5.0' в свое приложение gradle, а затем получил следующую ошибку при попытке построить свой проект:

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.

Мое приложение:

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>

Следуйте инструкциям : stackoverflow.com/a/54825603/1318946

Pratik Butani 12.03.2019 13:18
1
1
1 396
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Дело не в AndroidManifest.xml вашего приложения.

В сообщении об ошибке говорится, что существует конфликт между библиотекой поддержки совместимости 28.0.0 и другой библиотекой, использующей androidx. Я сомневаюсь, что эта полосатая библиотека построена с помощью androidx. 'ком. полоса: полоса-андроид: 8.5.0'

Вы можете решить эту проблему, переведя свое приложение на использование androidx вместо старых библиотек поддержки.

Ответ принят как подходящий

stripe-android использует AndroidX и включает класс CoreComponentFactory. На самом деле, в вашем проекте уже есть этот класс, поэтому попробуйте исключить модуль из gradle, который уже существует, или переопределите значения в файле манифеста, как это предлагает IDE, или перенесите свой проект на AndroidX из Refactor-> Migrate To AndroidX.

Другим решением является использование более старой версии полосовой библиотеки Android, которая не использует AndroidX внутри.

Другие вопросы по теме