Error build.gradle with com.google.android.gms:play-services-maps:9.4.0

馋奶兔 提交于 2020-01-04 04:02:10

问题


In my app I have these dependencies:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.package_app.name"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.android.support:design:23.2.1'
    compile "com.android.support:recyclerview-v7:23.2.1"
    compile 'com.android.support:cardview-v7:23.2.1'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
}

Below these dependencise I put

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

But I can't build app because return this error.

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 9.2.0.

So I tried to put

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

And the app build, so my question is: Why I can't use the last versione of services-map?


回答1:


I faced the same issue yesterday and solved it by doing the follows :

Firstly, make sure that you project/top level gradle file has the latest version for google services inside dependencies

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

Secondly, make sure to put the plugin at the bottom of the gradle app file

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

And make sure all google services dependencies including firebase are of the same version i.e. 9.4.0

compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'

This is what i currently have in my app.gradle dependencies.




回答2:


Add this line to end of build.gradle

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

And add this classpath (other build.gradle)

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



回答3:


It happens because you are using

compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'

As you can find in the pom file of these dependencies:

 <artifactId>firebase-analytics</artifactId>
  <version>9.4.0</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services-basement</artifactId>
      <version>9.2.0</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>

they are using the com.google.android.gms libraries with 9.2.0.

Use

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'



回答4:


Make sure in the root build.gradle you have the latest plugin reference.

Also if you recently updated the play services and all references are good - try to clean the gradle cache by calling rm -rf ~/.gradle/cache, sometimes it helps

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        //...
        classpath 'com.google.gms:google-services:3.0.0'
    }
}



回答5:


Change this :

compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'

by

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'


来源:https://stackoverflow.com/questions/39505402/error-build-gradle-with-com-google-android-gmsplay-services-maps9-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!