Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Support Library Setup error

Tags:

android

gradle

I followed instruction from http://developer.android.com/tools/support-library/setup.html to add the support library to my android project, but got an build error like this

Gradle: A problem occurred evaluating project ':projectname'.

No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [com.android.support:appcompat-v7:18.0.+] Possible solutions: module(java.lang.Object)

Does anyone know the reason for that? Is it a syntax error in gradle? Below is a piece of code in my build.gradle.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
        compile 'com.android.support:appcompat-v7:18.0.+'
    }
}
like image 960
Bai Avatar asked Dec 20 '22 21:12

Bai


1 Answers

This should be like this:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
        // this is for Gradle build system so it finds
        // android plugin used below
    }
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.+'
    // this is for your application
}

Don't forget to install Android Support Repository in Android SDK Manager.

like image 135
Grzegorz Żur Avatar answered Dec 26 '22 11:12

Grzegorz Żur