Gradle sync failed: Gradle DSL method not found: 'classpath()'

android

(dragos popa) #1

Im trying to build one of my android studio projects but everytime i try i get this

Gradle sync failed: Gradle DSL method not found: 'classpath()'

Here are my gradle files

` apply plugin: ‘com.android.application’

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.virtualflight.virtualcharts"
minSdkVersion 17
targetSdkVersion 25
versionCode 9
versionName "2.1.12"
multiDexEnabled true
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: [’.jar’], dir: ‘libs’)
androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2’, {
exclude group: ‘com.android.support’, module: ‘support-annotations’
})
compile ‘com.android.support.constraint:constraint-layout:1.0.2’
compile fileTree(dir: ‘libs’, include: [’
.jar’])
compile 'com.android.support:appcompat-v7:23.0.1’
compile 'com.android.support:design:25.3.1’
compile 'com.android.support:cardview-v7:25.3.1’
compile (‘com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar’){
transitive=true

classpath 'com.google.gms:google-services:2.3.0'

compile 'com.google.code.gson:gson:2.7'

compile 'com.github.bumptech.glide:glide:3.7.0'

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
testCompile 'junit:junit:4.12'

compile 'com.github.mancj:MaterialSearchBar:0.7'


compile 'com.mapbox.mapboxsdk:mapbox-java-core:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-geojson:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-services:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-java-services-rx:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.1.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-ui:2.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}

project level

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

buildscript {
repositories {
jcenter()

    maven { url 'https://maven.fabric.io/public' }
}

// move it here
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'

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

    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
}

}

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


(Stefan Oehme) #2

classpath ‘com.google.gms:google-services:2.3.0’

Should be

compile ‘com.google.gms:google-services:2.3.0’


(dragos popa) #3

nope, @st_oehme

get this :

Gradle sync failed: Could not find method compile() for arguments [com.google.gms:google-services:2.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Consult IDE log for more details (Help | Show Log)


(Stefan Oehme) #4

You have a missing } above that.


(dragos popa) #5

@st_oehme added it

`buildscript {
repositories {
jcenter()

    maven { url 'https://maven.fabric.io/public' }
}

}

// move it here
dependencies {
    compile 'com.google.gms:google-services:2.3.0'

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

    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
}

}

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

^ have no idea how to use them.

and now i get this

Gradle sync failed: Cause: startup failed:
build file ‘C:\Users\Dragos\AndroidStudioProjects\Virtualcharts\build.gradle’: 22: unexpected token: } @ line 22, column 1.
}
^
1 error
Consult IDE log for more details (Help | Show Log)


(Stefan Oehme) #6

Please make sure your brackets match up.