Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
}
like image 489
hyeri Avatar asked Apr 18 '26 02:04

hyeri


1 Answers

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).

like image 67
CommonsWare Avatar answered Apr 20 '26 14:04

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!