Reputation: 59
I am using Android Studio 3.0 Canary 6. I've been having some trouble with the build.gradle
(Project) file.
The build.gradle
file is as follows :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
ext.support_version = '26.0.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
classpath "org.jetbrains.kotlin:kotlin-gradle-
plugin:$kotlin_version"
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:recyclerview-v7:$support_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error that I get is :
Error:Error:line (13)Could not find method compile() for arguments [com.android.support:appcompat-v7:26.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager.
Please help me solve the error.
Upvotes: 1
Views: 1722
Reputation: 364471
You can't use these lines in your top level file:
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:recyclerview-v7:$support_version"
Remove them and use them in the module file.
Upvotes: 1
Reputation: 13865
Remove the compile
dependencies from the top level build.gradle
and put it in your app level build.gradle
dependencies
, which would be available under app/src
in Project view.
dependencies {
compile "com.android.support:appcompat-v7:26.0.1"
compile "com.android.support:recyclerview-v7:26.0.1"
}
The app level dependencies (which mostly starts with compile) should be put under app level build.gradle
file, and not under top level build.gradle
.
Actually, the build.gradle
file is written using Groovy language and compile
is a method invocation. In Groovy, we can leave the parenthesis for top-level expressions. And that's why you are getting an error like:
Could not find method complie()
Upvotes: 1