Search code examples
xmlandroid-studioandroid-theme

Cannot resolve symbol 'Theme' in Android Studio despite syncing project


My project builds and runs smoothly however in styles.xml the "Theme" is highlighted in red and this error is brought to my notice each time I commit my project to Git:

Error:(4, 36) Cannot resolve symbol 'Theme'

styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Note that I have tried syncing my project with gradle files and have ensured that google() is present in my buildscript block in build.gradle as mentioned in the answers to these questions:

1] Android Studio 3.0 cannot resolve symbol Theme

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

The accepted/top voted answers in these questions did not solve my problem, please help


Solution

  • To fix this problem delete these libraries from build.gradle

    com.android.support:appcompat-v7:27.1.1

    com.android.support:design:27.1.1

    sync and undo delete and sync again