Error (19.0) Gradle DSL method not found: android ()

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

Error (19.0) Gradle DSL method not found: android ()

... Below are the builds 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'
}

      

+3


source to share


3 answers


Here is an example build script and app.build.gradle

Remove everything after closing allprojects

from the top-level file build.gradle

, 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 closure android

specifically needs to be in a module that uses one of the Android Gradle plugins (for example com.android.application

).

+7


source


Remove this from the first code

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

      



See this

0


source


Problem:

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

Decision:

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.

0


source







All Articles