【问题标题】:Android google services plugin version conflict安卓谷歌服务插件版本冲突
【发布时间】:2018-10-03 03:46:42
【问题描述】:

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

版本冲突:

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/app

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.android.tools.build:gradle:3.0.0' 版本更改为类路径 'com.android.tools.build:gradle:3.0.1 并同步
  • 不是最新的 3.1.1
  • 是的。 3.1.1 是最新的.. 但既然你告诉版本正在恢复,只需尝试 3.0.1,然后再试一次 3.1.1
  • 在一些答案中,我在依赖项底部看到了插件。这也是一个问题,因为我将它放在顶部
  • 我认为这不重要.. 无论如何,我使用的是相同的 3.1 android studio 和 3.2.1 google 服务和 3.0.1 gradle,我最近更新到 3.1.1,同步没有任何问题.. 尝试使用 3.0.1 是否可以正常工作,然后尝试使用 3.1.1 看看是否有效

标签: android gradle


【解决方案1】:

最后移动这一行 应用插件:'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 脚本的底部并重建项目。

注意:-我认为它与引用有关 尚未创建的依赖项。像打电话一样的东西 在你声明它之前变量

【讨论】:

  • 这有什么不同?
  • @YashaswiNP 我认为它必须对尚未创建的引用依赖项做一些事情。就像在声明变量之前调用它。
  • @YashaswiNP 你是发布这个问题的人吗?
【解决方案2】:

请在您的应用构建中添加以下代码gradle.file

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

【讨论】:

    【解决方案3】:

    我希望这对你有用

    将您的类路径更改为 3.1.1

    classpath 'com.android.tools.build:gradle:3.1.1'
    

    并在app gradle文件中的依赖项之后应用插件

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多