【问题标题】:Adding firebase is conflicting with google play services添加 firebase 与 google play 服务冲突
【发布时间】:2019-04-17 11:45:43
【问题描述】:

自从将 Firebase 添加到我的应用程序以便我可以通过 appcenter 向用户发送推送通知后,我遇到了许多问题。

我目前遇到两个库之间可能存在的合并问题。

Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-basement is being 
requested by various other libraries at [[15.0.1,15.0.1]], but 
resolves to 16.0.1. Disable the plugin and check your dependencies 
tree using ./gradlew :app:dependencies.

正如您在此处看到的,我对 play-services-basement 没有任何特定的依赖项...

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'io.realm:realm-gradle-plugin:5.3.1'
    }
}


apply plugin: 'com.android.application'

apply plugin: 'io.fabric'

apply plugin: 'realm-android'

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

realm {
    syncEnabled = true
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.xxxxsoftware.xxxx.xxxx"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 36
        versionName "2.8.17"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {

        checkReleaseBuilds false

    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true
    }
    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 fileTree(include: ['*.jar'], dir: 'libs')
    def appCenterSdkVersion = '1.9.0'

    implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
    implementation "com.microsoft.appcenter:appcenter-push:${appCenterSdkVersion}"

    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.google.zxing:core:3.3.3'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'

    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
    implementation 'com.github.delight-im:Android-SimpleLocation:v1.0.1'
    implementation 'io.nlopez.smartlocation:library:3.3.3'
    implementation 'io.realm:android-adapters:3.0.0'
    implementation 'androidmads.library.qrgenearator:QRGenearator:1.0.3'
    implementation 'com.journeyapps:zxing-android-embedded:3.1.0@aar'
    implementation 'com.github.pwittchen:reactivenetwork-rx2:2.0.0'
}

我已经运行了命令 ./gradlew :app:dependencies 并打印出来:

* What went wrong:
Project 'app' not found in root project 'ChimePassportAndroid'.

【问题讨论】:

  • 您在代码中的哪个位置使用com.google.android.gms:play-services-basement?您是否将apply plugin: 'com.google.gms.google-services' 添加为文件的最后一行?
  • @AlexMamo 奇怪的是,我没有使用 play-services-basement... 我可以对其进行全局搜索,但什么也没有出现,我已经在 28 处应用了插件我正在应用我的其他插件(不需要在底部,就在标签之外)
  • 是的,它应该是 build.gradle 文件中的最后一行。您是否也尝试添加implementation 'com.google.firebase:firebase-messaging:17.3.4',以便能够使用通知?
  • @AlexMamo 我将插件留在原处,但添加了 firebase-messaging 库并且它工作了!谢谢你的帮助伙伴:)。生病必须向应用中心发送消息,并告诉他们修复他们的便便启动指南。

标签: java android firebase gradle


【解决方案1】:

为了使用 Firebase 消息传递,您需要在 build.gradle 文件中添加相应的依赖项,如下所示:

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

你的问题就解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-19
    • 2019-04-15
    相关资源
    最近更新 更多