【问题标题】:Should I add google-play service location dependencies or not if I had copy the google-service.json file into the Android Project如果我已将 google-service.json 文件复制到 Android 项目中,是否应该添加 google-play 服务位置依赖项
【发布时间】:2017-06-12 01:09:22
【问题描述】:

我已经通过 Firebase 控制台下载了我的 google-service.json 文件,并且该文件已添加到我的 android 项目文件中。我的问题是,如果我想在我的应用程序上进行融合定位,我仍然需要在依赖项中导入 google-service:location 吗?我对 firebase 的依赖项是 10.0.1 版本,因此如果我为我的最新版本 google-play 服务 11.0.0 放置依赖项,它将与我的 firebase 版本依赖项冲突。

这是我的 buil.gradle(应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
       applicationId "com.example.akmalnizarrosle.schoolbustracking"
       minSdkVersion 19
       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.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
}



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

【问题讨论】:

    标签: android json firebase dependencies


    【解决方案1】:

    是的,如果您想使用定位服务,您需要包含该 API 的库。您应该为 Firebase 和 Google Play 库使用相同的版本。 11.0.0 或 10.0.1 都可以,只要让它们都一样。最好使用最新的:

    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    
    compile 'com.google.firebase:firebase-auth:11.0.0'
    compile 'com.google.firebase:firebase-database:11.0.0'
    compile 'com.google.android.gms:play-services-location:11.0.0'
    

    【讨论】:

    • 我当前对 firebase 的依赖是使用 android studio 及其 10.0.1 版本中的 firebase 助手自动添加的。如果我想使用 google play 最新版本 11.0.0,我只是重新编号了 firebase 依赖项,或者我需要使用 sdk manager 或 firebase assistant 进行更新?
    • 只需将 Firebase 依赖项重新编号为 11.0.0
    • Tq 先生。我完成了你的解决方案。关于如何在注册的身份验证用户登录下将位置数据(纬度、经度)从 fusedLocation 保存到 Firebase 数据库中,您是否有任何回答?
    猜你喜欢
    • 2018-08-08
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 2018-06-27
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多