2
votes

I install the Android Studio and build a new project, but the automatic generated code show lots of "cannot resolve" errors like "cannot resolve symbol app" in the code "import android.support.v7.app.ActionBarActivity;"

The onCreate and setContentView Method cannot be resolved too

My Android Studio version is 0.4.2 , gradle version is 1.9

my build gradle is:

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

allprojects {
    repositories {
        mavenCentral()
    }
}

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
     versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}   

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}
2
Try rebuilding your project, then sync the project with the gradle files.Jonathon Fry
Thanks, but it doesn't work for meexcellent5

2 Answers

3
votes

You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.

Well that worked for me.

0
votes

Open your SDK Manager (you can find it in toolbar), and download

  • Android Support Repository and Android Support Library (you can find them in extras).
  • Google Repository and Google Play Service

Then sync your project with your gradle files (there is a button in toolbar).