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

本文档详细记录了作者在使用Android Studio 2.1.3创建项目时遇到的一系列问题,包括无法解析符号、方法覆盖错误及依赖下载失败等,并提供了项目的Gradle配置文件与SDK管理器截图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安果移不动

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值