Can't update to com.google.gms:google-services:4.2.0

前端 未结 4 1834
悲哀的现实
悲哀的现实 2021-01-05 12:09

At start google-services ver. is classpath \'com.google.gms:google-services:4.1.0\', but when I change it to 4.2.0 the error occurs during Sy

4条回答
  •  爱一瞬间的悲伤
    2021-01-05 12:49

    @NickUnuchek leave the dependencies block out of the gradle file of your root project, then it will work

    In result top level gradle:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    apply plugin: 'kotlin'
    
    buildscript {
        ext.kotlin_version = '1.3.20'
        repositories {
            google()
            jcenter()
            maven { url 'https://maven.fabric.io/public' }
            //region realm
            maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
            //endregion
        }
        dependencies {
            //region google()
            classpath 'com.android.tools.build:gradle:3.3.0'
            //endregion
            //region jcenter()
            classpath 'com.google.gms:google-services:4.2.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.orhanobut.tracklytics:tracklytics-plugin:2.0.0'
            //endregion
            //region maven { url 'https://maven.fabric.io/public' }
            //to check fabric gradle ver
            //https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
            classpath 'io.fabric.tools:gradle:1.+'
            //endregion
            //region realm
            classpath "io.realm:realm-gradle-plugin:5.8.0"
            //endregion
        }
    }
    
    allprojects {
        repositories {
            mavenLocal()
            google()
            jcenter()
            mavenCentral()
            maven { url 'https://maven.fabric.io/public' }
            maven { url "https://dl.bintray.com/nickunuchek/maven" }
            maven { url "https://jitpack.io" }
        }
    
        configurations.all {
            exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
        }
    }
    
    dependencies {
        //REMOVED FROM TOP-LEVEL implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    }
    
    compileKotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    compileTestKotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    

    app/build.gradle:

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'kotlin-kapt'
    
    android {
       ...
    
        defaultConfig {
         ...
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
    
    
        dexOptions {
            javaMaxHeapSize "8g"
            preDexLibraries = false
        }
    
        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }
    
    }
    
    dependencies {
      ...
      implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"//MOVED HERE FROM TOP-LEVEL GRADLE
    }
    
    apply plugin: 'com.google.gms.google-services'
    

提交回复
热议问题