[英]Gradle DSL method not found: 'android()'
I am using android studio 1.4 gradle version 2.4 android plugin version 1.3.0 我正在使用android studio 1.4 gradle版本2.4 android插件版本1.3.0
Error:(7, 0) Gradle DSL method not found: 'android()'
错误:(7,0)未找到Gradle DSL方法:“ android()”
Possible causes:
可能的原因:
The project 'Up_13_7_2015' may be using a version of Gradle that does not contain the method. 项目“ Up_13_7_2015”可能正在使用不包含该方法的Gradle版本。 Gradle settings
摇篮设置
The build file may be missing a Gradle plugin. 生成文件可能缺少Gradle插件。 Apply Gradle plugin
应用Gradle插件
Build.gradle file is Build.gradle文件是
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
apply plugin: 'announce'
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':Downloads:Android-ViewPagerIndicator-master:library')
classpath 'com.android.tools.build:gradle:1.3.0'
}
Look for the errors in your project-level build.gradle
file and fix them. 在项目级别的
build.gradle
文件中查找错误并进行修复。
In my case the issue appeared when I added new library module to the project. 就我而言,当我向项目中添加新的库模块时,问题就出现了。 My
build.gradle
looked like this: 我的
build.gradle
看起来像这样:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50' '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
As you can see this line is incorrect: 如您所见,这行是不正确的:
ext.kotlin_version = '1.3.50' '1.3.31'
I changed it to 我将其更改为
ext.kotlin_version = '1.3.50'
and I'm not getting the error anymore. 而且我不再收到错误了。
compile
语句必须位于应用程序模块的build.gradle
因此,如果将其从此文件中删除并添加到该文件中,它将起作用。
You need 你需要
apply plugin: 'com.android.application'
at the top of you app module build.gradle
file, before the android { }
. 在您的应用模块
build.gradle
文件顶部,在android { }
之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.