【问题标题】:Error when trying to add firebase libraries to app that uses google maps API尝试将 Firebase 库添加到使用 google maps API 的应用程序时出错
【发布时间】:2017-08-20 18:37:21
【问题描述】:

我有一个 Android 应用,我想添加 firebase 消息服务功能,以便接收从我的自建服务器发送到 firebase 云的通知。

我开始将配置行添加到 gradle 文件中,但在添加之后

应用插件:'com.google.gms.google-services'

行,我收到如下错误:

错误:任务 ':app:processDebugGoogleServices' 执行失败。 请通过更新 google-services 插件的版本(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新到 11.0.2 来修复版本冲突。

这是我的模块:app gradle 脚本文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "br.com.berait.brecar"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.android.gms:play-services-maps:11.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.wdullaer:materialdatetimepicker:3.2.2'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

如果需要,这是我的项目级 gradle 脚本文件:

//Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我已经搜索了 S.O 一段时间,但此类错误的所有答案都对我不起作用。如您所见,我在文件底部有应用插件行。我相信冲突是由

compile 'com.google.android.gms:play-services-maps:11.0.2'

行,它是在我向我的应用程序添加 google maps API 支持时自动添加的。

任何帮助表示赞赏,在此先感谢!

【问题讨论】:

    标签: android google-maps firebase firebase-cloud-messaging


    【解决方案1】:

    将firebase依赖版本提升到

    compile 'com.google.firebase:firebase-messaging:11.0.2'
    

    或将地图依赖降低到

    compile 'com.google.android.gms:play-services-maps:10.2.6'
    

    【讨论】:

    • 非常感谢,我知道就是这么简单
    猜你喜欢
    • 2014-07-16
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多