ChatGPT解决这个技术问题 Extra ChatGPT

Can't Find Theme.AppCompat.Light for New Android ActionBar Support

I am trying to implement the new ActionBar support library that was released by Google a couple days ago. In the past, I have successfully implemented ActionBarSherlock without any issues using the same method listed on Google Developer's Support Library Setup page - using the guide on how to include the resources (which is similar to how ActionBarSherlock did it). I have the library project loaded in to my own project as a library as well.

I can tell the library is loading fine. When, instead of extending Activity on my MainActivity.java, I changed it to extend ActionBarActivity (as per Google's instructions), no errors occur - and it imports correctly.

I even tried bypassing the style.xml file and adding @style/Theme.AppCompat.Light directly in to the AndroidManifest.xml for both <application> and <activity> with android:theme="@style/ThemeAppCompat.Light" with all attempts resulting in the same error.

Now the issue is I cannot get it to change the theme, let alone even build without throwing an error. Below is the error I am receiving, followed by the style.xml file I changed to use the new theme.

I have moderate experience working with Android apps and am running Eclipse with the latest version of the Support Libraries and SDK compiling with API 18 (Android 4.3).

Error Received During Build

error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Light'. styles.xml /ActBarTest/res/values line 3 Android AAPT Problem

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.ProsoftStudio.ACTest" parent="@style/Theme.AppCompat.Light">
    </style>
</resources>

Any suggestions? This was never an issue with ActionBarSherlock. I want to work on using this new support library. It almost seems like the .jar is loading, but not the resources.

Try to clean the project, maybe you need to reload the dependencies so that the styles from AppCompact can reload as well
@TheWizKid95 I did a clean up on my app I am trying to implement and the library. Neither one resulted in any changed code according to Eclipse and it did not fix any of the issues.
Have you added support library with Resources? Add jar to libs is not enough.
@GabrieleMariotti Yes I added the resources as well as a project library specially as Google instructed.
What worked for me was adding it as a project to the workspace. Just importing the jar and adding them to buildpath did not work.

W
W4R10CK

You need to do next:

File->Import (android-sdk\extras\android\support\v7). Choose "AppCompat" Project-> properties->Android. In the section library "Add" and choose "AppCompat" That is all!

Note: if you are using "android:showAsAction" in menu item, you need to change prefix android as in the example http://developer.android.com/guide/topics/ui/actionbar.html


This does not work for me. I do exactly what is written here, but end up with hundred of No resource found that matches given name errors. Resources, which missing are styles which are included from API 11 and above, but this thing should work from API 7. Is there some connection which I missing !?!
Having a similar problem, the Theme.AppCompat.Light.NoActionBar theme does not exist in my appcompat library.
Under File-Import I can`t find 'android-sdk'. I only see 'andoird'. Anyone?
apocalypz, I think you're missing the resources because you have imported the library without the resources. here is the link for "Adding libraries with resources" developer.android.com/tools/support-library/…
Following above steps + add sdk\extras\android\support\v13android-support-v13.jar to libs directory of project will resolve the issue.
m
marco110

If, like me, you are following the Android tutorial on http://developer.android.com/training/basics/actionbar/setting-up.html and keep getting this error, try to change the AppBaseTheme style in all styles.xml files. In detail:

In file res/values/styles.xml change the line: