Gradle DSL 方法不是 found:android()
Gradle DSL method not found:android()
错误:(1, 0) Gradle 未找到 DSL 方法:'android()'
可能的原因:
项目 'MyApp1' 可能正在使用不包含该方法的 Gradle 版本。
Gradle 设置构建文件可能缺少 Gradle 插件。
应用 Gradle 插件
Root/build.gradle
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
applicationId "com.example.shark.gpsapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
}
App/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.example.shark.myapp"
minSdkVersion 15
targetSdkVersion 21
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:22.2.1'
}
我无法打开我的任何旧 projects.Please 建议一个答案。
我在 android studio 更新后收到此错误。
在应用 android 插件 com.android.tools.build:gradle
之前,您不能调用 android
。
gradle 构建文件使用基于 Groovy 的 DSL,一种类似于 Java 的动态语言。 android { ... }
是对名为 android
的方法的调用,传递块。您收到的消息表明方法 android
尚未定义。它在插件中定义。
不知何故,您的根级别 build.gradle
文件与您的应用级别 build.gradle
几乎相同。不应该这样。
我建议您使用 Android Studio 创建一个全新的项目,并将其根级别 build.grade
文件复制到现有项目。
错误:(1, 0) Gradle 未找到 DSL 方法:'android()'
可能的原因:
Root/build.gradle
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
applicationId "com.example.shark.gpsapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
}
App/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.example.shark.myapp"
minSdkVersion 15
targetSdkVersion 21
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:22.2.1'
}
我无法打开我的任何旧 projects.Please 建议一个答案。 我在 android studio 更新后收到此错误。
在应用 android 插件 com.android.tools.build:gradle
之前,您不能调用 android
。
gradle 构建文件使用基于 Groovy 的 DSL,一种类似于 Java 的动态语言。 android { ... }
是对名为 android
的方法的调用,传递块。您收到的消息表明方法 android
尚未定义。它在插件中定义。
不知何故,您的根级别 build.gradle
文件与您的应用级别 build.gradle
几乎相同。不应该这样。
我建议您使用 Android Studio 创建一个全新的项目,并将其根级别 build.grade
文件复制到现有项目。