Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.


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.


No need to change anything.

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


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


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


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