Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 2.0 : Gradle DSL method not found: 'classpath()' error(27,0)

First of all, I've read all other solution posts and So far, none has worked. and I'm using Android Studio 2.0

Error: Error:(27, 0) Gradle DSL method not found: 'classpath()' Possible causes:

  • The project 'Sailu'sFood' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • here is build.gradle(app) :

         apply plugin: 'com.android.application'
    
              android
              {
                compileSdkVersion 23
                buildToolsVersion "23.0.2"
    
            defaultConfig {
                applicationId "com.example.kandarp.food"
                minSdkVersion 21
                targetSdkVersion 23
                versionCode 1
                versionName "1.0"
              }
               buildTypes {
                release {
                    minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'),         'proguard-rules.pro'
                  }
                 }
             }
    
                      dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            testCompile 'junit:junit:4.12'
            classpath 'com.google.gms:google-services:2.0.0-alpha6'
            compile 'com.android.support:appcompat-v7:23.1.1'
            compile 'com.android.support:design:23.1.1'
            compile 'com.google.android.gms:play-services-analytics:8.4.0'
            compile 'com.google.android.gms:play-services-ads:8.4.0'
                }
    
                 apply plugin: 'com.google.gms.google-services'
    

    here is build.gradle(top level) :

                 buildscript {
    
    
                repositories {
                    jcenter()
                }
    
                    dependencies {
    
                    classpath 'com.android.tools.build:gradle:2.0.0'
    
                }
    
    
    
            }
                  allprojects {
                repositories {
                    jcenter()
                }
            }
                task clean(type: Delete) {
                delete rootProject.buildDir
            }
    
    
                apply plugin: 'project-report'
                apply plugin: 'application'
    

    It'd really great if someone could point out what's the mistake

    like image 298
    nidhi pitroda Avatar asked Apr 08 '16 20:04

    nidhi pitroda


    1 Answers

    Remove this line from app/build.gradle from the dependencies block.

    classpath 'com.google.gms:google-services:2.0.0-alpha6'
    

    Then you have to move the line in the buildscript block (in the top-level file or in the module file):

     buildscript {
           repositories {
                jcenter()
           }
          dependencies {
                classpath 'com.android.tools.build:gradle:2.0.0'
                classpath 'com.google.gms:google-services:2.0.0-alpha6'
          }
    }
    
    like image 79
    Gabriele Mariotti Avatar answered Sep 21 '22 13:09

    Gabriele Mariotti