android - 在 Android Studio 项目中找不到参数的方法 android()

我正在尝试对我的 android studio 项目进行成绩同步,但标题中不断出现此错误。我的 build.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:2.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
repositories {
    jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
}
dependencies {

}

我的错误信息是

Gradle sync failed: Could not find method android() for arguments [build_aiwlctiq29euo9devcma4v4r7$_run_closure3@22efc0bc] on root project 'MyRadio

我在网上查看并尝试了多种解决方案,但似乎没有任何效果。这甚至意味着什么?任何帮助将不胜感激。

最佳答案

您使用了错误的 build.gradle 文件。

在您的顶级文件中,您不能定义一个 android block 。

只需将此部分移动到 module/build.Gradle 文件中即可。

android {
compileSdkVersion 17
buildToolsVersion '23.0.0'
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
apply plugin: 'maven'

https://stackoverflow.com/questions/40012866/

相关文章:

command-line - 如何自动化 Visual FoxPro 项目的构建?

ant - 如何在命令行上从属性文件加载 Ant 属性?

Xcode - 错误 : unable to open executable. ....如何修复?

php - 为什么要编译 PHP 文件?

build - 在 Windows 上是否有相当于 Make 的功能?

c++ - 在发布版本中保留调试符号有缺点吗?

java - 如何在 gerrit 中安装删除项目插件?

android - 错误 : could not load android-info. txt

java - 在 Netbeans 中自动生成源代码和 doc jar

java - 包括从 pom.xml 到应用程序包的应用程序版本号