user3607131
user3607131

Reputation: 173

Theme.AppCompat.Light resource not found in Android Studio

When trying to extend ActionBarActivity I need to use the AppCompat theme (Theme.AppCompat.Light). When I try to add it in the manifest and styles.xml I get

Error:(31, 28) No resource found that matches the given name (at 'theme' with value '@android:style/Theme.AppCompat.Light').

Eventhough I have downloaded the support libraries and included this in my build.gradle file ->

dependencies {
compile 'com.android.support:appcompat-v7:19.0.+'
compile 'com.android.support:support-v4:19.0.+'}

Upvotes: 15

Views: 30217

Answers (5)

seyed Jafari
seyed Jafari

Reputation: 1265

Invalidate Caches/restart in the file menu always does the job for me

Upvotes: 0

Daniel Nyamasyo
Daniel Nyamasyo

Reputation: 2312

What is happening is that the dependency responsible for that style is not being recognized.

just delete these from build.gradle if you have them:

'com.android.support:appcompat-v7:28.0.0'
'com.android.support:design:28.0.0'

then sync, then undo delete, then sync again.

Upvotes: 1

iltaf khalid
iltaf khalid

Reputation: 10318

Use Theme.AppCompat.Light instead of AppCompat.Theme.Light

Upvotes: 0

The Original Android
The Original Android

Reputation: 6215

From Android Studio, different than Eclipse:

  1. Open the build.gradle file for your application.

  2. Include the appcompat project and add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:

    dependencies { ... compile "com.android.support:appcompat-v7:18.0.+" }

  3. My note: In styles.xml, remove the reference to Android as in:

    style name="AppTheme" parent="Theme.AppCompat.Light"

For more details, read link

Upvotes: 5

user1652110
user1652110

Reputation: 430

In Android Studio, I had this same error when using android:theme='@android:style/Theme.AppCompat.Light but when I use android:theme="@style/Theme.AppCompat.Light" inside the AndroidManifest.xml file, the error is gone.

The difference appears to be from referring to an Android system wide provided theme "@android", to a locally defined theme "@style". Using the locally defined theme works due to having defined the gradle dependency on the appcompat library compile 'com.android.support:appcompat-v7:19.0.+', which is imported as a local theme.

For reference, the official documentation from Google for Android Developers around adding the ActionBar on Android devices 2.1+ instructs to use: android:theme="@style/Theme.AppCompat.Light" https://developer.android.com/training/basics/actionbar/setting-up.html

Upvotes: 24

Related Questions