在Android Studio项目中无法找到方法android()作为参数 [英] Could not find method android() for arguments in Android Studio project

查看:204
本文介绍了在Android Studio项目中无法找到方法android()作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的android studio项目上做一个等级同步,并且在标题中不断收到此错误。我的build.gradle文件是

I am trying to do a grade sync on my android studio project and I keep getting this error in the title. My build.gradle file is

// 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 {

}

我的错误信息是:

My error message is

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

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

I have looked online and tried multiple solutions but nothing seems to work. What does this even mean? Any help would be appreciated.

推荐答案

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

You are using the wrong build.gradle file.

在你的顶层文件中,你不能定义一个android块。

In your top-level file, you can't define an android block.

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

Just move this part inside the module/build.Gradle file.

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

这篇关于在Android Studio项目中无法找到方法android()作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆