g71132 g71132 - 24 days ago 14
Java Question

Cant import project in Android studio(Could not find method compile() for arguments)

Sorry for my english. I cant understand why i cant import project to my android studio. I have file build gradle

buildscript {
repositories {
jcenter()
}

dependencies {
compile 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
maven {
url "https://jitpack.io"
}
jcenter()
}
}

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


but i have error:


Error:(9, 0) Could not find method compile() for arguments
[com.android.tools.build:gradle:2.2.2] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open
File


why its mean?

Answer

You are using the wrong build.gradle file.

In your top-level file you can't define an android block.

Just move this part inside the module/build.gradle file.

Comments