java - list 合并失败:属性application @ appComponentFactory无法解决此问题

标签 java android firebase android-support-library androidx

我是android的新手,有一个应用在构建我的项目时出现此错误::


错误:清单合并失败:属性
application @ appComponentFactory
值=(androidx.core.app.CoreComponentFactory)来自
[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86也是
出现在[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91
值=(android.support.v4.app.CoreComponentFactory)。意见建议:添加
'tools:replace =“ android:appComponentFactory”'元素
在AndroidManifest.xml:9:5-44:19进行覆盖。


我的Gradle版本是::

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

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "maa.tic_tac_to"
        minSdkVersion 19
        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'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //   implementation 'com.android.support:appcompat-v7:24.2.1'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    // implementation 'com.android.support:support-v4:28.+'
    // implementation ('com.theartofdev.edmodo:android-image-cropper:2.4.+'){

       // exclude group: 'com.android.support'
    //}
    // implementation 'com.google.android.material:material:1.0.0-alpha08'

    implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta2'
    // implementation 'com.androidx.constraintlayout.widget:ConstraintLayout:2.0.0-beta2'
    testImplementation 'junit:junit:4.12'
}


和manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="maa.tic_tac_to">

    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/tic_tac_toe"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">


        <activity android:name=".MainActivity"></activity>

        <receiver
            android:name=".MySMSReceiver"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <activity android:name=".FakeActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".LogInActivity"></activity>


        <service
            android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>

</manifest>


我测试stackoverflow和google搜索中的每个解决方案,但有人可以帮助我。
任何人都可以帮助解决此错误吗?!?!?!?

最佳答案

您正在使用

implementation 'com.google.firebase:firebase-messaging:19.0.1'


Firebase在最新版本中已迁移到AndroidX。
这意味着您同时使用了支持库和androidx库。

您可以:


如下所述迁移至androidx
降低您的Firebase依赖项降级(但这不是真正的解决方案,因为您迟早要迁移)


您可以检查official release notes


警告:此版本是主要版本更新和重大更改。
Google Play服务和Firebase的最新更新包括以下更改:


从Android支持库迁移到Jetpack(AndroidX)库。除非您在应用中进行以下更改,否则库将无法工作:


com.android.tools.build:gradle升级到v3.2.1或更高版本。
compileSdkVersion升级到28或更高版本。
更新您的应用程序以使用Jetpack(AndroidX);请按照Migrating to AndroidX中的说明进行操作。

关于java - list 合并失败:属性application @ appComponentFactory无法解决此问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57020612/

相关文章:

java - 消灭敌人的有效方法

java - 在 RESTLET 中读取 Web-INF 中的配置文件

java - if else 语句

android - Android ListView 项目中的长字符串

firebase - 如何更改 Firebase 主页目标

java - 使用 Spring Mail 将电子邮件保存到已发送文件夹中

java - 如何关闭突出通知?

android - 无法在 Anko 中调用 StartActivityForResult

javascript - 如何在 Google Cloud Function 中获取原始请求正文?

javascript - 公理 : Request header field Access-Control-Allow-Methods is not allowed by Access-Control-Allow-Headers in preflight respones