【问题标题】:what versions of firebase and google maps should i use?我应该使用什么版本的 firebase 和谷歌地图?
【发布时间】:2018-12-16 18:52:46
【问题描述】:

我尝试在同一个应用程序中使用 firebase 和 Google 地图,但每次同步 gradle 文件时都会出现以下错误: 请通过更新 google-services 插件的版本(有关最新版本的信息可在https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新到 16.0.1 来修复版本冲突。

我已尝试更改播放服务版本,但这并没有解决问题。 下面是两个gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.myteam"
        minSdkVersion 23
        targetSdkVersion 27
        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'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.android.gms:play-services-maps:16.0.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'
}

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

根项目build.gradle:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.1.1'   
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

【问题讨论】:

    标签: android firebase google-maps


    【解决方案1】:

    Android Studio 应该告诉您哪些版本已经过时了……通常以黄色背景表示 - 并且当用鼠标悬停这些更新建议时会显示更新建议。告诉它是如何工作的可能比做你的工作更好。

    buildscript {
        ...
        dependencies {
            classpath "com.android.tools.build:gradle:3.2.1"
            classpath "com.google.gms:google-services:4.2.0"   
        }
    }
    

    这至少应该可以解决一个问题,而另一个 build.gradle 的版本已经过时了。

    【讨论】:

    • 我已经应用了您建议的更改并更新了 build.gradle 版本,它已经消除了错误,谢谢。
    猜你喜欢
    • 2010-10-20
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2015-05-29
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多