Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:+'
}
like image 635
jd50 Avatar asked Nov 05 '13 02:11

jd50


2 Answers

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.

like image 194
ticofab Avatar answered Nov 07 '22 11:11

ticofab


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
    }
}
like image 21
mindeh Avatar answered Nov 07 '22 10:11

mindeh