Sachin Titus
Sachin Titus

Reputation: 2349

Cannot add compile 'com.android.support:design:27.0.2' to The Build Gradle

I'm getting this particular error and my SDK Manager says the Support Directory is already installed.

`Error:(11, 0) Could not find method compile() for arguments [com.android.support:design:27.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Please install the Android Support Repository from the Android SDK Manager.
<a href="openAndroidSdkManager">Open Android SDK Manager</a>`

Thanks in advance!

Upvotes: 2

Views: 3931

Answers (3)

yuva
yuva

Reputation: 1

Make sure that you are adding dependencies in your

project>app>build.gradle

not in your

project>build.gradle

Upvotes: -1

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364644

You are adding the dependencies in the wrong part.
Don't add the support libraries in the buildscript block and don't add them in the top-level file.

repositories { 
        google() 
        jcenter() 
        maven { url "maven.google.com"; /i added this line } 
     } 
    dependencies { 
        classpath 'com.android.tools.build:gradle:3.0.1' 

        REMOVE THESE LINES !!!

        compile  'com.android.support:appcompat-v7:27.+' //i added this line 
        compile 'com.android.support:design:27.+' // i added this line This is the only place where changes are made
    }

Upvotes: 2

Marcus
Marcus

Reputation: 162

Replacing 27.0.2 with 27.+ is considered bad practice. Make sure that you are adding the dependency in the correct Gradle file app/build.gradle in the dependencies{} block.

Upvotes: 0

Related Questions