Android Studio 在编译项目时出现此错误。我搜索了一下,发现这可能是因为
android
阻塞在 build.gradle 的顶部。但在我的 build.gradle 中它可能不是问题所在。 这是我的 gradle 文件。
构建.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 {
应用程序.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'
最佳答案
在应用该插件之前,您正在使用 Android 插件中定义的 Gradle 域特定语言 (DSL)。
删除
android {
compileSdkVersion 19
}
在您的顶级 build.gradle 中。您的应用程序 build.gradle 文件中已经有 compileSdkVersion 20
,它确实很重要。
now its showing "Error:(16, 0) Gradle DSL method not found: 'runProguard()'
runProguard
前段时间在 Android Gradle 插件中被重命名为 minifyEnabled
。您还应该在构建脚本中重命名它。
关于android - 错误 :(19, 0) 找不到 Gradle DSL 方法: 'android()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29913502/