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

只愿长相守 提交于 2019-12-06 02:49:23

问题


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'

}


回答1:


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.




回答2:


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()
}

}



来源:https://stackoverflow.com/questions/29913502/error19-0-gradle-dsl-method-not-found-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!