Android Studio) Сбой слияния манифеста - PullRequest
0 голосов
/ 13 апреля 2020

во-первых, мой модуль build.gradle выглядел следующим образом:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.depressionanalysis"
        minSdkVersion 27
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    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.guava:guava:27.0.1-jre'
    implementation 'com.loopj.android:android-async-http:1.4.9'
}

, что привело к следующему предупреждению: «Файл gradle приложения должен зависеть от com.google.firebase: firebase-core для служб Firebase чтобы работать как задумано. "

, поэтому я попытался добавить его (и обновил также Firestore)

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.depressionanalysis"
        minSdkVersion 27
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.2'
    implementation 'com.google.firebase:firebase-core:17.3.0'
    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.guava:guava:27.0.1-jre'
    implementation 'com.loopj.android:android-async-http:1.4.9'
}

, но получил эту ошибку

" 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.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:10:5-46:19 to override. "

Как сделать я чиню это? Я опробовал несколько решений, найденных здесь, но безрезультатно. Заранее спасибо! Дайте мне знать, если нужны какие-либо другие коды !!

Ответы [ 3 ]

0 голосов
/ 13 апреля 2020

На самом деле, для одной и той же библиотеки у вас есть разные версии из разных источников, у вас есть библиотека поддержки, а также их версия AndroidX. На данный момент вы можете попробовать решить ее, используя атрибут

tools:replace="android:appComponentFactory

, как указано в самой ошибке.

Go в свой файл AndroidManifest добавьте этот атрибут, как показано ниже.

<application
        android:name=".AbcApplication"      
        tools:replace="android:appComponentFactory
        >
</application>
0 голосов
/ 13 апреля 2020

для меня я добавил два атрибута в AndroidMenifest. xml

    tools:replace="android:appComponentFactory"
    android:appComponentFactory="androidx"

полный тег это как:

 <application
    android:allowBackup="true"
    android:icon="@mipmap/logo"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/logo"
    android:theme="@style/AppTheme"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="androidx"
    tools:ignore="GoogleAppIndexingWarning">

и ваш проект должен быть в Androidx.

0 голосов
/ 13 апреля 2020

Вы используете последнюю версию firestore:

com.google.firebase:firebase-firestore:21.4.2

, и в июне 2019 года firebase начал поддерживать androidX, поэтому вам нужно перейти на androidX, чтобы иметь возможность использовать firebase.

Обновленные библиотеки не будут работать, если вы не внесете следующие изменения в свое приложение:

  1. Обновите ком. android .tools.build: переходите к v3.2.1 или новее.
  2. Обновите compileSdkVersion до 28 или более поздней версии.
  3. Обновите ваше приложение для использования Jetpack (AndroidX); следуйте инструкциям в разделе «Миграция на AndroidX».

Проверьте, как выполнить миграцию:

https://developer.android.com/jetpack/androidx/migrate

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...