[英]Could not find method android() for arguments [build..] on root project '..' of type org.gradle.api.Project
The following shows up when I'm tryig to work: 当我尝试工作时,将显示以下内容:
Could not find method android() for arguments [build_9cxkoz5xxe5p8ydg2a1ig2k7b$_run_closure1@7b0f017] on root project 'dangerous-forest-game-android' of type org.gradle.api.Project.
在根项目“ dangerous-forest-game-android”类型为org.gradle.api.Project的参数[build_9cxkoz5xxe5p8ydg2a1ig2k7b $ _run_closure1 @ 7b0f017]上找不到方法android()。
I have been looking for a solution to my problem, but I found my syntax is too different. 我一直在寻找解决问题的方法,但是我发现语法太不一样了。 Here is the code of my
android()
function : 这是我的
android()
函数的代码:
android {
buildToolsVersion "19.1.0"
compileSdkVersion 20
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
You have to use the android
DSL only in your app/build.gradle
file and not in the root/build.gradle
file. 您只需要在
app/build.gradle
文件中使用android
DSL,而不必在root/build.gradle
文件中使用。
Also you have to apply the android plugin in the app/build.gradle
file before using it. 另外,在使用前,您必须在
app/build.gradle
文件中app/build.gradle
android插件 。 Check the official doc . 检查官方文档 。
/**
* The first line in the build configuration applies the Android plugin for
* Gradle to this build and makes the android block available to specify
* Android-specific build options.
*/
apply plugin: 'com.android.application'
/**
* The android block is where you configure all your Android-specific
* build options.
*/
android {
//.....
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.