Cannot resolve symbol 'Theme' in styles.xml (Android Studio)

Screenshot

Since today, Android Studio can't find the AppCompat themes in styles.xml, but for example AppCompatActivity in code does get recognized. My Android Studio version is 2.2.2, Build #AI-145.3360264

I already tried upgrading to the latest build tools, compile sdk (25) version etc. but it didn't fix the problem.

At the moment I have installed the following (from sdk manager):

  • android api: 19 and 23
  • sdk platform tools: 25.0.1
  • sdk tools: 25.2.3
  • build-tools: 23.0.2 and 25.0.1
  • support repository: 40
  • google repository: 39

and a few others, that shouldn't be necessary to list here.

build.gradle of app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/RootTools.jar')
    compile 'com.android.support:support-v4:23.+'
    compile 'com.android.support:support-v13:23.+'
    compile 'com.android.support:appcompat-v7:23.+'
    compile 'com.android.support:design:23.+'
    compile 'com.android.support:cardview-v7:23.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
}

Solution 1:

Another solution that worked for me with Android Studio 3.1.2:

delete these from build.gradle if you have them:

'com.android.support:appcompat-v7:27.1.1' 'com.android.support:design:27.1.1'

then sync, then undo delete, then sync again.

Solution 2:

I encountered this after updating to Android Studio 3.1.

None of the other answers listed here worked for me, however when I switched my appcompat support lib version to the latest 28.0.0-alpha1 then back to 27.1.0 that it was on before, it worked.

Seems the new version of Android Studio lost connection to where the library was synced to and just needed to have it reset.

Solution 3:

No need to change anything.

Just press small button on top "Sync Project with Gradle Files"