找不到参数的方法 android()

Could not find method android() for arguments(找不到参数的方法 android())
本文介绍了找不到参数的方法 android()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将项目导入 Android Studio,这就是我卡住的地方,Stack Overflow 但它没有为我的特定错误提供解决方案.

I've been trying to import a project to Android Studio and this is where I am stuck, there is a similar question on Stack Overflow but it did not provide a solution to my particular error.

这是我的错误日志:

C:<some location>uild.gradle

Error:(24, 1) A problem occurred evaluating root project '<project name>'.
> Could not find method android() for arguments [build_4fli1jm76ubcnxesnhqnhie47$_run_closure3@6e71db85] on root project '<project name>'.
Information:BUILD FAILED

Gradle 同步消息是:

The Gradle sync messages are:

错误:(24, 0) Gradle DSL 方法未找到: 'android()' 可能原因:

  • PoojaPeople"项目可能正在使用不包含该方法的 Gradle.Gradle 设置
  • 构建文件可能缺少 Gradle 插件.申请Gradle 插件
  • Error:(24, 0) Gradle DSL method not found: 'android()' Possible causes:

  • The project 'PoojaPeople' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 我不太确定这个方法 android() 的确切位置.如果它是位于 Application 的 build.gradle 文件中的那个,我仍然不知道从这里去哪里.任何帮助表示赞赏.

    I'm not too sure where exactly this method android() is located. If it is the one located in Application's build.gradle file, I still don't exactly know where to go from here. Any help is appreciated.

    我的 build.gradle

    buildscript {
        repositories {
            maven { url "http://dl.bintray.com/populov/maven" }
            mavenCentral()
        }
         dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            maven { url "http://dl.bintray.com/populov/maven" }
            mavenCentral()
    
        }
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    android {
        compileSdkVersion 17
        buildToolsVersion '23.0.0'
    }
    dependencies {
        compile files('app/libs/junit-4.12-JavaDoc.jar')
    }
    apply plugin: 'maven'
    

    推荐答案

    你使用了错误的 build.gradle 文件.

    在您的顶级文件中,您无法定义 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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

    本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

    相关文档推荐

    How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
    Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
    How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
    How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
    Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
    Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)