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

AndroidAndroid StudioGradleAndroid AppcompatAndroid Styles

Android Problem Overview


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'
}

Android Solutions


Solution 1 - Android

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 - Android

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 - Android

No need to change anything.

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

Solution 4 - Android

EDIT: As @Alexey noted, bug still appears in Android Studio v3.1.4

This worked for me:

  • Click File > Close Project
  • Reopen the project from Studio's dialog.

enter image description here

Solution 5 - Android

That's because of feature called "build cache" that is enabled by default in build Android Plugin since 2.3.0. It creates files in build cache outside of project folder (in my case -- in \Users%username%\.android\build-cache) Theese files are intended to be common between your projects.

And then Android Studio is unable to navigate in theese files. That's all.

If you want to disable Build Cache, add android.enableBuildCache=false to gradle.properties file. Then restart Android Studio.

more info here: https://developer.android.com/studio/build/build-cache.html#disable_build_cache

Solution 6 - Android

I have had the same problem. The only solution that worked for me was to manually delete the support libraries in file system and sync the project to let Android Studio download them again.

Steps:

  1. Go to your project folder in File system
  2. Go to .idea\libraries
  3. Delete all the Gradle__com_android_support_****.xml files
  4. Open Android Studio
  5. Select File > Sync with File System
  6. Once that is done, Select File > Sync Project with Gradle Files
  7. Build Project

And now your error should be gone!!!

Solution 7 - Android

you can hit file -> invalidate Caches / Restart ... if it doesn't fix the issue you can close the project (file-> close project) and import it (file -> new -> import project.

Solution 8 - Android

I switched support lib to version 27.1.1 and problem has been solved. Seems like some bug in 27.1.0

Solution 9 - Android

I went through the same problem when I upgraded to alpha-2.

I looked at this link: http://tools.android.com/recent, but the only thing that worked well was:

Change this: Classpath 'com.android.tools.build:gradle:2.3.0-alpha2'

For this: Classpath 'com.android.tools.build:gradle:2.2.3'

In your build.gradle (Project)

Solution 10 - Android

Only this worked for me
  • Close project (File> Close Project)
  • Import / Re-Open project again (NOT from Recent)

Error should be resolved now.

If that fails, try below-

  • Open build.gradle, remove appcompact-v7 dependency and sync project.
  • Add appcompact-v7 dependency and sync.

Solution 11 - Android

I encountered same problem like this.Just the difference is I was using Studio 2.2.3. This is what solved my problem:

In my project level gradle I had:

classpath 'com.android.tools.build:gradle:2.3.0-alpha2' (which was a result of updating studio)

which I replaced with: classpath 'com.android.tools.build:gradle:2.2.3'

I think you should look for a compatible classpath for your gradle configuration.

Solution 12 - Android

I was having the same issue after linking Firebase to my app. Updating the build.gradle in the app module did the trick, updated to:

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.8.0'

Solution 13 - Android

I had also the same problem when I upgraded my android studio from 2.2.2 to 2.3 Canary Version. Although the new beta version of 2.3 is released yet it is using the gradle plugin of 2.2.3 which is of stable version.

So just change the classpath dependency in buildscript of build.gradle project level from alpha to 2.2.3 and sync it. It'll resolve the issue or change to the more appropriate version with respect to your channel version.

More on gradle watch this Gradle Recipes for android Ken Kousen - Gradle Summit 2016

https://www.youtube.com/watch?v=4L6wHTVmxGA

Solution 14 - Android

In newer versions of Android Studio, we are asked to use 'AppCompat'. Some users uncheck that and still use the Theme.AppCompat. That makes up this error. Same happened with me.

Solution is to add this line in your build.gradle (app).

compile 'com.android.support:appcompat-v7:26.1.0'

Solution 15 - Android

@Daniel Wilson made a comment in one of the answers that solved this issue for me. I wanted to add add as an answer to draw more attention to this solution.

Updating compileSdkVersion and targetSdkVersion from 26 to 27 (and then of course updating the dependencies) eliminated the errors for me.

Solution 16 - Android

Mine was fixed by deleting the .gradle file from the folder and re-importing the project in Android Studio

Solution 17 - Android

I also faced the problem with Android Studio 3.1 , syncing does not help me.

Then I switched back to

`'com.android.support:design:27.1.0'` from : `'com.android.support:design:27.1.1'`

and added android.enableBuildCache=false to gradle.properties to disable build cache

Solution 18 - Android

This is weird, I encounter this problem as below:

  • Android Studio is 3.1.2
  • support lib version is 27.0.0

I solve this by below:

  1. change support lib version to 27.1.0, and "Sync Project with Gradle Files", then this error disappear
  2. change support lib version to 27.0.0,and "Sync Project with Gradle Files", then this error not appear again

Solution 19 - Android

Deleted .idea and .gradle from project folder. Then sync with gradle files, it worked.

Solution 20 - Android

I changed my gradle version from

classpath 'com.android.tools.build:gradle:2.3.0'

to

classpath 'com.android.tools.build:gradle:2.2.3'

and it works now!

Solution 21 - Android

I ran into the same problem when updating the Android Studio software. What I did was this:

> Go to the Gradle Settings as follows (this path is for Mac, but should be similar on Windows): > > Android Studio -> Preferences -> Build, Execution, Deployment -> > Gradle. > > Then pick "Use default gradle wrapper (recommended)".

If you already have that option chosen then your problem must lie somewhere else.

Solution 22 - Android

In Android Studio 3.1.3, the simple work around:

"Sync Project with Gradle Files"

Solution 23 - Android

If none of these methods mentioned by other contributors does not work for you..

Then please simply ignore this...

Even flutter officials also said to ignore these errors..

Caution*** Only ignore after trying all the methods.If above methods solve your errors then fine otherwise you can ignore these..

This type of errors happen after installing latest version of flutter sdk,gradle ,android studio and other plugins -packages

If you are using latest version then you have to ignore these errors.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFLPView Question on Stackoverflow
Solution 1 - AndroidM D PView Answer on Stackoverflow
Solution 2 - AndroidkassimView Answer on Stackoverflow
Solution 3 - AndroidVadimView Answer on Stackoverflow
Solution 4 - AndroidΕυάγγελος ΜπίληςView Answer on Stackoverflow
Solution 5 - AndroidbabayView Answer on Stackoverflow
Solution 6 - AndroidTricky BayView Answer on Stackoverflow
Solution 7 - AndroidMarco TView Answer on Stackoverflow
Solution 8 - AndroidSergey BondarenkoView Answer on Stackoverflow
Solution 9 - AndroidDuan BressanView Answer on Stackoverflow
Solution 10 - AndroidKhemraj SharmaView Answer on Stackoverflow
Solution 11 - AndroidApoorv KarkareView Answer on Stackoverflow
Solution 12 - AndroidJessie ColmeneroView Answer on Stackoverflow
Solution 13 - AndroidKarthik SaxenaView Answer on Stackoverflow
Solution 14 - AndroidTheOnlyAnilView Answer on Stackoverflow
Solution 15 - AndroidseekingStillnessView Answer on Stackoverflow
Solution 16 - AndroidIoannis IView Answer on Stackoverflow
Solution 17 - AndroidNazmul Alam KhanView Answer on Stackoverflow
Solution 18 - AndroidzhangliangView Answer on Stackoverflow
Solution 19 - Androidn1m1View Answer on Stackoverflow
Solution 20 - AndroidAmeya DaphalapurkarView Answer on Stackoverflow
Solution 21 - AndroidREG1View Answer on Stackoverflow
Solution 22 - AndroidWaqar UlHaqView Answer on Stackoverflow
Solution 23 - Androidraman ramanView Answer on Stackoverflow