hyeri
hyeri

Reputation: 693

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

I just upgraded android studio and the previously compiled project is now showing errors!

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

, Here is the build script and app.build.gradle

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'

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

   android {
    defaultConfig {
    minSdkVersion 8
    targetSdkVersion 22
}
productFlavors {
}
  }

 dependencies {
}

and here is the build.gradle

 apply plugin: 'com.android.application'

  android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.aqsa.personal.newpro"
    minSdkVersion 8
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {

        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

   dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile 'com.android.support:appcompat-v7:21.0.3'
}

Upvotes: 3

Views: 4731

Answers (3)

Nagashree
Nagashree

Reputation: 105

Problem:

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

Solution :

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
}
allprojects {
    repositories {
        jcenter()
    }
}

Remove after allprojects code, and build project.this solution works for me.

Upvotes: 0

Matteo Basso
Matteo Basso

Reputation: 2704

Remove this from the first code

android {
    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
    }
    productFlavors {
    }
}

See this

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007349

Here is the build script and app.build.gradle

Remove everything after the allprojects closure out of the top-level build.gradle file, leaving you with:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'

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

The android closure, in particular, needs to be in a module that is using one of the Gradle for Android plugins (e.g., com.android.application).

Upvotes: 7

Related Questions