【问题标题】:Can't build project after adding firebase dependency [duplicate]添加firebase依赖项后无法构建项目[重复]
【发布时间】:2019-08-09 22:57:29
【问题描述】:

我正在尝试测试 FCM,但在添加了 firebase-messaging 依赖项后,应用无法构建。我收到“警告:API 'variant.getMergeResources()' 已过时并已替换为'variant.getMergeResourcesProvider()' 的警告。 它将在 2019 年底被删除。”

我得到的错误是:

"使用groupId com.android.support 和androidx.* 的依赖不能 合而为一 IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='appcompat-v7', myVersion='28.0.0', myPacking='aar', myClassifier='null'} 和 IdeMavenCoordinates{myGroupId='androidx.slidingpanelayout', myArtifactId='slidingpanelayout', myVersion='1.0.0', myPacking='aar', myClassifier='null'}...

上线:

implementation 'com.android.support:appcompat-v7:28.0.0'

我尝试了一种解决方案,该解决方案涉及向 gradle 文件添加一些“configurations.all”选项,但没有奏效。我已经尝试将 firebase 的版本更改为较早的版本,但这也不起作用。

这是我构建的那个模块级别的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.hfad.fcm"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7: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-messaging:19.0.1'
}

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

【问题讨论】:

    标签: android firebase android-studio android-support-library androidx


    【解决方案1】:

    错误说你不能合并 appcompat 和 androidx 库,所以将你的依赖项移动到 androidx ,你应该使用 androidx 库:

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    

    在这里你可以看到我自己对 firebase 消息的依赖:

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    

    从这里查找版本https://developer.android.com/jetpack/androidx/migrate

    【讨论】:

    • 我已经这样做了,但我仍然收到一个模糊的错误“清单合并失败并出现多个错误,请参阅日志”我实际上不知道我应该查看哪些日志,因为日志都在说同样的事情
    • @Deeswoc 打开您的清单,然后使用底部的“Meged manifest”选项卡查看您的合并清单。你可以在那里看到错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 2020-05-14
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多