Could not find method getCompileConfiguration() for arguments[]

半世苍凉 提交于 2019-12-22 08:15:15

问题


I'm getting the following error.

Could not find method getCompileConfiguration() for arguments [] on object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.


回答1:


I was facing similar issue and after spent some time over internet I found below solution. If you are using latest version of google-services in build.gradle then following changes need to be done :-

1) In project level build.gradle

        buildscript {
            repositories {
                jcenter()
                mavenLocal()
                maven {
                    url 'https://maven.google.com/'
                    name 'Google'
                }
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.1.2'
                classpath 'com.google.gms:google-services:3.3.1'
            }
        }

        allprojects {
            repositories {
                jcenter()
                mavenLocal()
                maven {
                    url 'https://maven.google.com/'
                    name 'Google'
                }
            }
        }

2) In App level build.gradle

android{
    //All other
    buildToolsVersion '27.0.3'
    }
        dependencies {
        // All other
            implementation 'com.google.firebase:firebase-database:15.0.1'
        }
        apply plugin: 'com.google.gms.google-services'

3) In gradle-wrapper.properties

distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip




回答2:


we had the same problem... solved by upgrading gradle in gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip

and the gradle plugin in gradle.build

repositories {
    google()
    ...
}

dependencies {
    ...
    classpath 'com.android.tools.build:gradle:3.1.0'
}


来源:https://stackoverflow.com/questions/50131089/could-not-find-method-getcompileconfiguration-for-arguments

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