BRDroid
BRDroid

Reputation: 4388

Cannot resolve symbol Theme, ThemeOverlay

I updated my android studio to latest version - 3.0.1. Since then it complains 'Cannot resolve symbol' for Theme and ThemeOverlay in the following lines of code. App runs fine but they are marked in RED in the file.

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
 <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

build.gradle is updated with the latest version

 dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }

Upvotes: 23

Views: 21017

Answers (7)

linjiejun
linjiejun

Reputation: 1698

In my case , I have already defined the value in styles.xml file but it still notice me the problem like this:

the value has been defined

But I still got an error like below:

enter image description here

I solve this problem by change the value like below:

enter image description here

Hope this is work for you too.Thank you!

Upvotes: 0

zulu_papa
zulu_papa

Reputation: 415

Invalidate Caches / Restart from file menu solved it for me. Didn't see the same answer below

Upvotes: 0

Tayyab Mazhar
Tayyab Mazhar

Reputation: 1712

I had this same error so i compared it to gradle file of another project which wasn't showing error. In your build.gradle(Module:app) under dependencies, add the following line:

implementation 'com.android.support:preference-v7:28.0.0'

Upvotes: 1

Carlos B. Flores
Carlos B. Flores

Reputation: 2879

Something got messed up on the indexing of the Project when you updated the version.

To fix go to the menu:

File -> Invalidate Caches/Restart

that will reopen and re-index the whole project, the error should be gone.

Upvotes: 4

Khemraj Sharma
Khemraj Sharma

Reputation: 59004

Found Easiest Way

  • Close project (File> Close Project)
  • Import / Re-Open project again (NOT from Recent)

The error should be gone.

If(that_did_not_work)

  • Open build.gradle, remove appcompact-v7 dependency and sync.
  • Again add that dependency and sync.

Error Gone!

Upvotes: 2

V.March
V.March

Reputation: 1840

1)Close the project from the File menu.

2)Open the project again as existing Android Studio project.

enter image description here

This fix my problem.

Upvotes: 29

Nikita Karamov
Nikita Karamov

Reputation: 884

  1. In the app/build.gradle remove the line responsible for the appcompat package (something like implementation 'com.android.support:appcompat-v7:27.1.1')
  2. Perform the Gradle sync. It will break and show a lot of errors
  3. Bring the original line back
  4. Perform the Gradle sync once again

This will magically solve the problem that for no reason appeared in the 3.0.1

Upvotes: 15

Related Questions