Skip to content Skip to sidebar Skip to footer

Build Script Error, Unsupported Gradle Dsl Method Found: 'android()'!

I'm using Android Studio 0.4.5 and having troubles syncing gradle. When I try to do that I get this error: Gradle 'MyApp' project refresh failed: Build script error, unsupported Gr

Solution 1:

The main reason was having this:

android {    
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }
}

in the root build.gradle.

Solution 2:

Remove following lines of code from Module1 build.gradle file :

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

As you are using the same configuration across all your modules, so it is fine to have it in root gradle file only.

Even if you want it in module's build.gradle file this code should be before applying android plugin.

Final Module1 build.gralde file :

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

Also make sure below mentioned configuration should be same across the modules

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"
    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
 }

You can use whatever you want but should be same.

Post a Comment for "Build Script Error, Unsupported Gradle Dsl Method Found: 'android()'!"