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

后端 未结 23 2101
半阙折子戏
半阙折子戏 2020-11-27 11:56

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

相关标签:
23条回答
  • 2020-11-27 12:37

    In Android Studio 3.1.3, the simple work around:

    "Sync Project with Gradle Files"

    0 讨论(0)
  • 2020-11-27 12:39

    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

    0 讨论(0)
  • 2020-11-27 12:40

    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

    0 讨论(0)
  • 2020-11-27 12:40

    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!

    0 讨论(0)
  • 2020-11-27 12:41

    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)

    0 讨论(0)
  • 2020-11-27 12:41

    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.
    0 讨论(0)
提交回复
热议问题