我想同时使用firebase和谷歌地图

时间:2017-08-16 06:44:31

标签: android google-maps firebase gradle

与标题一样,我想同时使用firebasegoogle map。 当我单独尝试时,它没有任何错误。但如果我尝试使用它全部错误!任何人都可以帮我解决这个问题吗?我试图找到一些问题,但multidex或更新级别相同并不适用于所有。

这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "MY-APPLICATION-ID"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.github.paolorotolo:appintro:4.0.0'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.android.support:design:25.3.1'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    testCompile 'junit:junit:4.12'
}





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

这是我的gradle错误.. :(

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.0.

4 个答案:

答案 0 :(得分:3)

将版本降低到与Firebase相关性相同,反之亦然

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

compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'    
compile 'com.google.android.gms:play-services-maps:11.0.4'

答案 1 :(得分:1)

确保您拥有相同版本 firebase和谷歌地图

compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'    
compile 'com.google.android.gms:play-services-maps:11.0.4'

答案 2 :(得分:0)

尝试使用与Google相同版本的谷歌

var dte = '2017-08-16T05:47:42.070Z';
var dt  = new Date(dte);

var myFrmt = dt.getFullYear().toString() + (dt.getMonth()+1).toString() + dt.getDate().toString();

alert(myFrmt);

答案 3 :(得分:0)

使用最新版本的firebase和地图for Example. 11.0.4

compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'

并确保您使用项目的gradle文件

classpath 'com.google.gms:google-services:3.1.0'