简体   繁体   English

在类型为org.gradle.api.Project的根项目'..'上找不到参数[build ..]的方法android()

[英]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.

相关问题 找不到参数 org.gradle.api.Project 的方法 android() - Could not find method android() for arguments org.gradle.api.Project 错误:无法在 org.gradle.api.Project 类型的根项目上找到 arguments 的方法 install() - Error: Could not find method install() for arguments on root project of type org.gradle.api.Project 无法为参数org.gradle.api.Project找到方法android() - Could not find method android() for arguments org.gradle.api.Project 错误:(16,0)找不到类型为org.gradle.api.Project的根项目'delta-bartalk'上的参数的方法android() - Error:(16, 0) Could not find method android() for arguments on root project 'delta-bartalk' of type org.gradle.api.Project 在 org.gradle.api.Project 类型的根项目“android”上找不到参数 [build_1c6nueis8xobld9$_run_closure2@7bfda345] 的方法 android() - Could not find method android() for arguments [build_1c6nueis8xobld9$_run_closure2@7bfda345] on root project 'android' of type org.gradle.api.Project 无法为 org.gradle.api.Project 类型的项目“:app”的参数找到方法 androidTestCompile() - Could not find method androidTestCompile() for arguments on project ':app' of type org.gradle.api.Project 无法为 org.gradle.api.Project 类型的项目“:app”的参数找到方法 buildTypes() - Could not find method buildTypes() for arguments on project ':app' of type org.gradle.api.Project 在 org.gradle.api.Project 类型的项目“:app”上找不到 arguments 的方法 dataBinding() - Could not find method dataBinding() for arguments on project ':app' of type org.gradle.api.Project Flutter 无法在 org.gradle.Z8A5DA52ED1264741A83 类型的项目 ':app' 上找到 arguments [] 的方法 Properties() - Flutter Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project 如何处理“无法在项目中找到方法android()'的错误:org.gradle.api.Project类型的app'” - How to handle error of “Could not find method android() on project ':app' of type org.gradle.api.Project”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM