【问题标题】:ERROR: Could not find method android() for arguments错误:找不到参数的方法 android()
【发布时间】:2019-12-01 22:50:53
【问题描述】:

我遇到了一个问题,当我同步我的项目时,会出现这个 gradle 错误:(

错误: 在 org.gradle.api.Project 类型的项目 ':app' 上找不到参数 [build_4igxve2xutpcfkae0ab7hnkia$_run_closure1@353dd2ed] 的方法 android()。 打开文件

这是我的 Build.gradle(project: name)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:3.0.0-beta6'
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:4.3.2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的 build.gradle(Module:App)

apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.instagram"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'


    implementation 'com.google.firebase:firebase-analytics:17.2.0'
//androidTestImplementation 'com.android.support.test:runner28.0.0'
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

    标签: java android gradle


    【解决方案1】:

    您的模块的 build.gradle 文件顶部似乎缺少这一行:

    apply plugin: 'com.android.application'
    

    【讨论】:

    • 我添加了这个并且没有发生另一个错误.....ERROR: ASCII Open File
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    相关资源
    最近更新 更多