Android 谷歌服务插件版本冲突

标签 android gradle

我最近将 Android Studio 升级到 3.1,我遇到了版本冲突问题。我的 Gradle 版本是 4.4,Andoid 插件 版本是 3.0.0。我尝试将其更改为 3.1.1。它恢复为以前的版本号。这让我感到困惑,所以需要你的帮助。同步时,我在构建中收到以下消息。

版本冲突:

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

build.gradle/应用

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

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.globemaster.samples"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        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.0.0'
    implementation 'com.android.support:design:27.0.0'
    implementation 'com.payumoney.sdkui:plug-n-play:1.2.0'
    implementation 'com.google.firebase:firebase-auth:15.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.firebase:firebase-core:15.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation 'com.google.android.gms:play-services-location:15.0.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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



        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

最佳答案

最后移动这一行 应用插件:'com.google.gms.google-services'

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.globemaster.samples"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        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'])
    //
    //
}
apply plugin: 'com.google.gms.google-services'

在 (app)build.gradle 脚本的底部并重建项目。

Note:- I think that it has to do something with referencing dependencies that have not yet been created. Something like calling a variable before you even declare it

关于Android 谷歌服务插件版本冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49975293/

相关文章:

android - 如何修复向 Google 日历添加事件时出现的 "Error connecting with login URI"异常?

java - Android:为什么我的 if 语句没有在 onClick 方法内执行

android - 为什么 gradle 说它无法解析 "com.android.support:support-annotations:23.1.1"?

java - 在gradle中运行带参数的jar

java - Jenkins、Gradle、clean 可以工作,但编译 Java 失败(权限被拒绝)

android4.4使用ant构建apk,如何使用 "renderscriptSupportOutOut"属性?

安卓的东西 :Use Speech to text in Raspberry Pi 3 using android things

android - app:compat-v7:28.0.0和play-services-vision:18.0.0之间不兼容的appcompatpat和play-services-vision依赖性

java - 在 ViewPager 的滑动上停止 Exoplayer

testing - 如何配置gradle以输出执行的测试总数?