Michael Bouix
Michael Bouix

Reputation: 45

Error:(22, 0) Could not find method android() for arguments

I tried to run my app and got this erro, help me please.

// 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.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // 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 {
    signingConfigs {
        config {
        }
    }
    buildToolsVersion '24.0.2'
    compileSdkVersion 24
    buildTypes {
        buildType {
            signingConfig signingConfigs.config
        }
    }
}
dependencies {
}

ERROR:

Error:(22, 0) Could not find method android() for arguments [build_exkifxt5bplscorlvh4v3btv2$_run_closure3@981984c] on root project 'Recipe App' of type org.gradle.api.Project.

Upvotes: 0

Views: 2368

Answers (3)

shoriwa-shaun-benjamin
shoriwa-shaun-benjamin

Reputation: 807

Add this line:

apply plugin: 'com.android.feature'

To the top of the problematic build.gradle file and sync again.

Upvotes: 1

Munir sf
Munir sf

Reputation: 36

I faced same problem and SOLVED IT BY:

  1. Open your ‘build.gradle’ file and you find the following may be your comiple version is different but I want t show the file structure. android { compileSdkVersion 25 buildToolsVersion '25.0.2' } dependencies { } The error happens because similar android declaration is in other build.gradle file. therefore remove both the android and dependencies.

for more details here

Upvotes: 0

No Name
No Name

Reputation: 1

// 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.3.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 25
    buildToolsVersion '25.0.2'
    dexOptions {
        incremental true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
dependencies {
    compile files('app/libs/junit-4.12-JavaDoc.jar')
}
apply plugin: 'maven'`enter code here`

Upvotes: 0

Related Questions