【问题标题】:Failed to resolve: com.google.android.support.gms:play-services-map:10.2.0无法解决:com.google.android.support.gms:play-services-map:10.2.0
【发布时间】:2018-08-08 00:01:27
【问题描述】:

我正在尝试使用 Google 的功能创建 Google 地图,但是当我尝试同步项目时出现此错误

这是 build.gradle 文件..

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

android {

    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.example.chamiya.bustracking"
        minSdkVersion 16
        targetSdkVersion 24
        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(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // can update the Firebase

    compile 'com.google.android.gms:play-services:11.4.2'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.0'
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'
    compile 'com.firebaseui:firebase-ui-database:1.2.0'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.support.gms:play-services-map:10.2.0'
    testCompile 'junit:junit:4.12'

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

【问题讨论】:

  • 哪个错误?错误在哪里?
  • 能否请您发布错误信息?

标签: android google-maps firebase android-gradle-plugin google-play-services


【解决方案1】:

无法解决:com.google.android.support.gms:play-services-map:10.2.0

它发生是因为它不存在:

用途:

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

而不是

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

在任何情况下,您都必须在 build.gradle 中进行一些更改:

  1. 对于支持 firebase 库和 google play services 库,您必须使用相同的版本

例如使用最新的 v11.8.0

compile 'com.google.android.gms:play-services:11.X.X'
compile 'com.google.firebase:firebase-database:11.x.x'
compile 'com.google.firebase:firebase-auth:11.x.x'
compile 'com.google.android.support.gms:play-services-map:11.x.x'
  1. 更新你的compileSdkVersion

  2. 使用firebase-ui 库的compatibile version

  3. 删除文件顶部的apply plugin: 'com.google.gms.google-services'

【讨论】:

  • 当我使用这个 compile 'com.google.android.gms:play-services-maps:x.x.x' 它显示了这个服务的可用版本。它解决了这个问题。谢谢你的回答。
猜你喜欢
  • 2017-07-17
  • 2019-04-15
  • 2018-11-06
  • 2018-11-23
  • 2018-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-09
相关资源
最近更新 更多