kunal007
kunal007

Reputation: 19

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

here's my gradle file

I am getting this error

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

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

android {
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
}
productFlavors {
}
}
dependencies {
}

Upvotes: 1

Views: 2040

Answers (2)

Abhishek Jain
Abhishek Jain

Reputation: 3702

You need to apply a plugin to your build.gradle file. Only then you will be able to use the android block. Add any of these two lines at the top of your build.gradle file:

  • Application : apply plugin: 'com.android.application'
  • Library : apply plugin: 'com.android.library'

Upvotes: 3

Armen Hovhannisian
Armen Hovhannisian

Reputation: 952

Your App Gradle should look like something like this

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.armenhovhannisyan.backpaper.backpaper"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.0-beta1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:design:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

}

Upvotes: 1

Related Questions