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.
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
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).
3. Add new Module from existing sourse to your IDEA project.
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.
2. Add next to build.gradle
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.
you need reference $ANDROID_SDK/extras/android/support/v7/appcompat
You had better make new project with any name , then use appcompat_v7 that program make new .
In the section library
Add
and choose library appcompat.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.
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.