zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Cannot resolve symbol 'AppCompatActivity' , Cannot resolve symbol 'R', Could not download support-co

not symbol Cannot could support resolve Download co
2023-09-27 14:27:47 时间

I installed Android Studio 2.1.3, and successfully created a new project (just call it ProA),it runs well in AVD. That time I had just only downloaded the sdk platform android-24 . I created that project with the Minimum SDK API 14. Acutally , I didn't download android-14 that time.
Then latter I downloaded android-14, androdi-15,android-21,android-23, tried to create a new project (call it ProB), but many errors occurred there.

  1. The MainActivity's superclass is AppCompatActivity , but the error is Cannot solve symbol 'AppCompatActivity'.

  2. There is a red line under the @Override tag over the onCreate() method,saying that Method does not override method from its superclass

  3. In onCreate() method ,the setContentView(R.layout.activity_main) code snippet shows Cannot resolve symbol 'R'.

  4. The Messages window has a error message saying
    A problem occurred configuring project ':app'.
    Could not download support-compat.aar(com.android.support:-compat:24.2.0): No cached version available for offline mode

the overall picture is like this: the overall error image(click to see)

the content of app\src\build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.zhangsir.aftervpn"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
}

the content of gradle\build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

the screenshot of the standalone sdk manager (click to see)


modified at 2016 Aug,27

I have downloaded all the Android SDK Build-tools:Android SDK Build-tools


What can I do to solve this problem?