错误:找不到方法android()作为参数

时间:2019-09-21 13:28:21

标签: java android gradle

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

  

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

这是我的Build.gradle(项目:名称)

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

1 个答案:

答案 0 :(得分:1)

您似乎在模块的When executing my code on a 16 cpu, 32gb memory server I'm receiving this result: 1.045549364 1.030857833 1.0466020120000001 1.0309665050000003 1.0464690349999994 1.046397238 1.0309525370000001 1.0312070380000007 1.0307592159999999 1.046095523 Im expacting the result to be: 1.041549364 1.041857833 1.0416020120000001 1.0419665050000003 1.0414690349999994 1.041397238 1.0419525370000001 1.0412070380000007 1.0417592159999999 1.041095523 文件顶部缺少此行:

build.gradle