jd50
jd50

Reputation: 255

Android Studio build.gradle - Cannot resolve symbol 'android'

I've gone through the tutorial here and everything works except for my build.gradle. Everything in the 'android' section is is underlined and displays a "Cannot resolve symbol" error message. This is in Android Studio 0.3.1. I've even tried re-installing Android Studio and it still doesn't work.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}

Upvotes: 8

Views: 21936

Answers (2)

ticofab
ticofab

Reputation: 7717

I've had it recently with Android Studio 1.3. The only working solution was to remove the .gradle and .idea folders and re-import it in Android Studio.

Upvotes: 4

mindeh
mindeh

Reputation: 1818

Seems like you've got version mismatch and Android Studio or Gradle fails to resolve dependencies.

First update Android SDK - update to latests versions, be sure to get SDK platforms v18 & v19.

Then decide which version you're targeting - v18 or v19. If v18, then android section of build config should look like

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18
    }
}

and if targeting v19:

android {
    compileSdkVersion 19
    buildToolsVersion "19"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
}

Upvotes: 2

Related Questions