12

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.

miken32
  • 42,008
  • 16
  • 111
  • 154
Heyya
  • 193
  • 1
  • 1
  • 7

5 Answers5

8

Move your android{} part to this file build.gradle

Ajith Pandian
  • 1,332
  • 13
  • 21
6

Edit this gradle file currently you are editing top level gradle file but you have to edit App level

add dependencies over there.

Rajesh Satvara
  • 3,842
  • 2
  • 30
  • 50
2

Each module you add in your Android Studio Project has its own build.gradle file. Any dependencies that you want to add is added in associated module build.gradle file. So in your case you have to add your dependencies in your app's build.gradle file.

Here is an image showing where you should add that.

Build Gradle

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
2

Refresh gradle after deleting the below

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
}
dependencies {

}

It works for me

Umino
  • 31
  • 3
1

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.

Nikunj Paradva
  • 15,332
  • 5
  • 54
  • 65