Could not find method android() for arguments org.gradle.api.Project

前端 未结 4 770
-上瘾入骨i
-上瘾入骨i 2021-02-13 14:20

Getting a bug, when I try to compile my project in studio , i have search quite a bit with no real solution to it

Error:(17, 0) Could not find method android() for argu

相关标签:
4条回答
  • 2021-02-13 15:00

    Invalidate Cache and restart

    Go to : File/Invalidate Cache/Click on Invalidate and Restart This should solve your problem for you.

    0 讨论(0)
  • 2021-02-13 15:20

    There are two build.gradle files. One is in the top-level holder, and the other is in module holder.

    Below is an example.

    Top-level build.gradle:
    https://github.com/nickbutcher/plaid/blob/master/build.gradle

    module's build.gradle:
    https://github.com/nickbutcher/plaid/blob/master/app/build.gradle

    The android block should be in module's build.gradle. I guess you must have defined the android block in top-level build.gradle which is causing the error.

    0 讨论(0)
  • 2021-02-13 15:23
    buildscript {
    
        ext.versions = [
                'compileSdk'    : 27,
                'targetSdk'     : 27,
                'buildTools'    : '27.0.3',
                'butterknife'   : '8.8.1',
                'glide'         : '4.6.1',
                'kotlin'        : '1.2.21',
                'retrofit'      : '2.3.0',
                'supportLibrary': '27.0.2'
        ]
    
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.0-alpha01'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
        }
    
    }
    
    0 讨论(0)
  • 2021-02-13 15:24

    I had same problem if your android block is in module's build.gradle and use google services, just add these 2 lines before android block:

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

    0 讨论(0)
提交回复
热议问题