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

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

Brandon Enriquez
1#
Brandon Enriquez Published in 2013-07-26 00:15:29Z
 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  and  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   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.
W4R10CK
2#
 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
crossle
3#
 you need reference \$ANDROID_SDK/extras/android/support/v7/appcompat
skia.heliou
4#
 I did the following in Eclipse with the Android Support Library (APL) project and the Main Project (MP): Ensured both APL and MP had the same minSdkVersion and targetSdkVersion. Added APL as a build dependency for MP: Going into "Properties > Java Build Path" of MP, and then Selecting the "Projects" tab and adding APL. In the properties of MP, under "Android", added a reference to APL under library. 1 and 2 got the references to Java classes working fine...however I still saw the error in the manifest.xml for MP when trying to reference @style/Theme.AppCompat.Light from APL. This only went away when I performed step 3.
Community
5#
 I will share my experience with this problem. I was going crazy because of this, but I found out that the problem was a bug with Eclipse itself, rather than my code: In eclipse, unable to reference an android library project in another android project So, if you have the Android Support Library in your C: drive and your project in the D: drive on your computer, Eclipse won't function correctly and won't know where the Android Support Library is (green tick turns into red cross). To solve this, you need to move both projects onto the same hard drive.
i_am_leo
6#
 Follow the steps of @rcdmk. Delete the android support v4.jar in YOUR project. It conflicts with the new updated version found in appcompat.
marco110
7#
 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: 
Joe C
8#
Joe C Reply to 2014-01-25 18:27:46Z
 http://developer.android.com/tools/support-library/setup.html has a bug. In Property->Java build path->'Project' and 'Order and Export', there should not be any jar's. Removing them, and checking 'Android Private Libraries' and 'Android Dependencies' solved my problem.
David Douglas
9#
David Douglas Reply to 2014-03-15 17:59:02Z
 This is an issue that can happen in Android Studio if you modify Project Structure Modules. In this case you may need to add the dependencies again. In a text editor edit the 'build.gradle' file to include the required dependencies: dependencies { compile 'com.android.support:appcompat-v7:+' compile fileTree(dir: 'libs', include: ['*.jar']) }  This should update your '{your_project_name}.iml' file with lib components:  
Riddhi Dudani
10#
Riddhi Dudani Reply to 2014-09-21 07:09:41Z
 I made a really silly mistake for this. When I was getting same error every time i could not figure out what was wrong. then it clicked me that once I have closed all the projects in my work space and that was the time since all the problems started. SO just check whether your "appcompat_v7" is not closed. If it is then open the project by double click and then clean and build your project again. In my case the errors were gone. Happy coding!
swap_1712
11#
 I am not sure whether v13 support library was available when this question was posted, but in case someone is still struggling, I have seen that adding android-support-v13.jar will fix everything. This is how I did it: Right click on the project -> Properties Select Java Build Path from from the left hand side table of content Go to Libraries tab Add External jars button and select \extras\android\support\v13\android-support-v13.jar
syildizeli
12#
 I had same problem and waste my 4-5 hours for solution. My problem solved with; From SDK manager delete packages "Android Support Library" and " Android Support Repository". Reinstall "Android Support Library" and " Android Support Repository" Remove "android-support-v7-appcompat" or "appcompat_v7 what else you have in your project. Import android-support-v7-appcompat from "adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat" Select your project and from file choose properties and find Java Build Path and then from "Project" tab delete what else there and then Add. and you must see "android-support-v7-appcompat" , select and add it to Project tab. Check your project.properties file below your Project files, you will see like this; target=android-21 android.library.reference.1=../android-support-v7-appcompat then check AndroidManifest.xml file if target is 21 or what else you choosed. Also check for library reference same as your library that choosed before. Hope you will find your solution.
Yin
13#
 works:  
Wasim A.
14#
Wasim A. Reply to 2014-11-24 17:17:46Z
 My issue resolve via following Steps File->Import (android-sdk\extras\android\support\v7\appcompat) Right Click Project-> properties->Android. In the section library "Add" and choose library appcompat that's include in step 1 Delete all files from project's libs directory add following file to project's libs directory \extras\android\support\v13android-support-v13.jar Restart Eclipse if required. That's it. Your problem should be disappeared.
BostonGeorge
15#
 For Android Studio or IntelliJ, all you need to do is update your dependencies in gradle.build. I used the following: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.2' } 
ban-geoengineering
16#
 I experienced the same problem as the OP after right-clicking on my project and selecting Close Unrelated Projects. In my case, I resolved the problem by re-opening the appcompat_v7 project and cleaning/rebuilding both projects.
Allan Pereira
17#
Allan Pereira Reply to 2016-09-04 22:20:24Z
 For IntelliJ IDEA or Android Studio: Add this to app.gradle build file dependencies { compile "com.android.support:appcompat-v7:21.0.+" }  Replace -v:xx.0+, with your build target, if you have 19 platform then it must be like: dependencies { compile "com.android.support:appcompat-v7:19.0.+" } 
Youngsup Kim
18#
Youngsup Kim Reply to 2015-01-13 18:11:06Z
 It happened to me when Eclipse(Luna)/AndroidSDK(not Android Stduio) were used with the latest tools and library as of Jan. 14, 2015 during the project like HelloWorld. When I installed those tools and made HelloWorld the first app, I accepted all the defaults. - This is the problem in my case. First, check whether or not the "Android Support Library" library is installed. If not, install it. It is not installed by default. You may do it all in "Android SDK manager" available in the menu. (Android SDK Manager -> Extra -> Android Support Library) Blessings, (a debtor)<><
Jesus Dimrix
19#
Jesus Dimrix Reply to 2015-01-14 15:28:15Z
 Quickest solution : right click on the project - > Android tools -> Add support library..
qwertz
20#
 Since the Import dialouge is different in Android Studio 1.0.1, I could't get Svyatoslav Lobachs version to work. Instead I downloaded "Android Support Repository" in the SDK Manager. Then added dependencies { ... compile "com.android.support:appcompat-v7:18.0.+" }  to build.gradle. Worked for me.
Isham
21#
 I dont know how many of you noticed this. Support library "appcompat_v7" and your project should be in a same directory(I mean workspace directory). Dont clean your project until its error free else you will have tough time with R.java
22#
 You had better make new project with any name , then use appcompat_v7 that program make new . Right Click Project-> properties->Android  In the section library Add and choose library appcompat.
Rahul
23#
 in eclipse right click on your project-> select build path and then select configure build path. from the window select the jar file that you want and refresh your project
18446744073709551615
24#
 The accepted solution used to work for me once, but not now. I had to re-create a hello-world of the same kind (!) in a new workspace, made it compile, and then copied all directories, including .hg and .hgignore. hg diff shows: - android:targetSdkVersion="19" /> + android:targetSdkVersion="21" /> Binary file libs/android-support-v4.jar has changed  It looks like Eclipse wants to compile for API 21 and fails to do anything with API 19. Darkly.
Alex Jolig
25#
Alex Jolig Reply to 2016-02-16 08:03:27Z
 For Android Studio 1.2.2 Drop "android" from the parent attribute value:  
Rahul Kumar
26#
Rahul Kumar Reply to 2015-06-26 21:16:30Z
 Its bit late but here is how I get it done in AndroidStudio ! Right click on app to goto properties Go to Dependencies and click on '+' sign and choose library dependency Choose appcompat-v7
Suraj Dubey
27#
Suraj Dubey Reply to 2015-07-29 02:39:15Z
 If you have added appCompat Library and also have given proper reference of appCompat from SDK location, try "invalidate caches/Restart". You can find it from "File" menu in Android Studio.
Iuliia Ashomok
28#
Iuliia Ashomok Reply to 2015-11-05 21:59:05Z

IntelliJ IDEA solution.

1. Run Android SDK Manager and install the latest SDK and Android Support Libarary. The version of SDK and Android Support Libarary should be the same! 23 in my case. Another variants will give you the errors.

2. Change SDK version of your IDEA project to the last one you installed in previous step. (ps. you may not use Maven).

4. Add AppCompat project. !!! Should be under the last SDK too! (ps. Say "Yes" anywhere in process of this step)

5. Open settings of your main Project Module and add to it next 3 dependecies:

5.1. Module Dependency. Chose android-support-v7-appcompat

5.2. 2 pc. Library Dependencies. Add android-sdk\extras\android\support\v7\appcompat\libs\android-support-v4.jar and android-support-v4\android-support-v7-appcompat.jar

In total it will be:

6. Very important!!!
Add theme with prefix @style (not another!).

Android Studio solution.

1. Run Android SDK Manager and install the latest SDK and Android Support Libarary. The version of SDK and Android Support Libarary should be the same! 23 in my case. Another variants will give you the errors.

dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
}


P.S. If you are new in Android developing, I strongly recomend you move to Android Studio & Gradle right now - you will get the simplest way of managing your android app.

Barbaros Erdogdu
29#
Barbaros Erdogdu Reply to 2015-12-31 12:53:26Z
 In my case the problem occurred since I wanted to use a SDK that doesnt include the required library. When I increased the min. SDK level the problem dissappeared. Of course directly including the library's itself, should remove the error as well.
Rohit Rokde
30#
Rohit Rokde Reply to 2016-02-08 13:36:30Z
 Forget everything. Just use the appcompat library downloaded using the Android Studio. It has all the missing definitions. No matter whether you are using in Eclipse or not.
API
31#