Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method android() for arguments in Android Studio project

I am trying to do a grade sync on my android studio project and I keep getting this error in the title. My build.gradle file is

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
}
dependencies {

}

My error message is

Gradle sync failed: Could not find method android() for arguments [build_aiwlctiq29euo9devcma4v4r7$_run_closure3@22efc0bc] on root project 'MyRadio

I have looked online and tried multiple solutions but nothing seems to work. What does this even mean? Any help would be appreciated.

like image 921
Heyya Avatar asked Oct 13 '16 05:10

Heyya


2 Answers

You are using the wrong build.gradle file.

In your top-level file, you can't define an android block.

Just move this part inside the module/build.Gradle file.

android {
compileSdkVersion 17
buildToolsVersion '23.0.0'
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
apply plugin: 'maven'
like image 64
Atman Bhatt Avatar answered Oct 28 '22 22:10

Atman Bhatt


Check if your APP Level Build.Gradle is missing Plugin

then Add apply plugin: 'com.android.application'

in APP Level Build.Gradle

From My solution.

like image 26
Nikunj Paradva Avatar answered Oct 28 '22 21:10

Nikunj Paradva