6

I'm getting the following error in Android Studio 0.4.2 when I'm trying to Sync project with gradle.

Gradle 'GooglePlayServicesTest' project refresh failed:
       Build script error, unsupported Gradle DSL method found: 'android()'!

My projects gradle file is as follows :-

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.7.+'
}
}

allprojects {
repositories {
    mavenCentral()
}
}


android{

compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}

sourceSets{
    main{
        manifest.srcFile 'GooglePlayServicesTest/src/main/AndroidManifest.xml'
    }
}
}

gradle file of module:-

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
  }
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}

also I have removed the miniSDKVersion and targetSDKVersion from AndroidManifest.xml

can someone help me to solve this error.

helloworld
  • 965
  • 5
  • 14
  • 34
  • Replace runProguard with minifyEnabled [Click Here][1] to view Details.. [1]: http://stackoverflow.com/questions/27078075/gradle-dsl-method-not-found-runproguard/27266373#27266373 – Amitabha Biswas Dec 08 '14 at 10:26

2 Answers2

19

android method in project gradle file is not needed.Try to remove it.

fookwood
  • 488
  • 4
  • 10
  • If you want to make build changes for your module, do so in the module's build.gradle file. You're getting this error because there's no module at the project root. Having said that, I'm not sure what you're trying to do with setting the location of your AndroidManifest.xml file; that should be unnecessary in most cases. – Scott Barta May 01 '14 at 15:43
  • @fookwood What do you mean get rid of 'android' method? Where will you specify minSdkVersion and targetSdkVersion? – IgorGanapolsky Jul 23 '14 at 16:06
  • specify *SdkVersion in your module's build.gradle file – fookwood Jul 24 '14 at 07:44
2

Add top of your project build.gradle file:

apply plugin: 'com.android.application'
Pokechu22
  • 4,984
  • 9
  • 37
  • 62
hamid
  • 21
  • 1