Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:(19, 0) Gradle DSL method not found: 'android()'

Android Studio is giving this error while compiling the project. I have searched and found that this may happen because of

android

Block in top of the build.gradle.But in my build.gradle it may be not the problem. here is my gradle files.

build.gradle

 // 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:1.1.0'

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

android {
compileSdkVersion 19
}
dependencies {

}

app.gradle

  apply plugin: 'com.android.application'

  android {
  compileSdkVersion 20
  buildToolsVersion "20.0.0"

    defaultConfig {
    applicationId "com.ptrprograms.chromecast"
    minSdkVersion 14
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
 }
  buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),    'proguard-rules.pro'
    }
  }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:mediarouter-v7:19.0.+'
compile 'com.google.android.gms:play-services:6.1.11'

}

like image 580
san88 Avatar asked Apr 28 '15 07:04

san88


People also ask

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.


2 Answers

You're using Gradle domain-specific language (DSL) defined in the Android plugin before applying that plugin.

Remove the

android {
compileSdkVersion 19
}

in your top-level build.gradle. You already have compileSdkVersion 20 in your app build.gradle file where it actually matters.

now its showing "Error:(16, 0) Gradle DSL method not found: 'runProguard()'

runProguard was renamed to minifyEnabled in the Android Gradle plugin some time ago. You should rename it in your build script as well.

like image 113
laalto Avatar answered Oct 16 '22 08:10

laalto


Not Solved: I'm using gradle-experimental for doing NDK stuff.

Error:(13, 0) Dexcount plugin requires the Android plugin to be configured MY Top level build.gradle file:

buildscript {

repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle-experimental:0.4.0'
}

}

allprojects {

repositories {
    jcenter()
}

}

like image 34
Anish Mittal Avatar answered Oct 16 '22 09:10

Anish Mittal