Android Styles and Values issue - android

My Android project was working fine when I noticed that I had checked SDK version 4.2 when I meant to target Google 2.33. I set the project back to G2.33 (In the manifest it minsdk = 8 targetsdk=11) and now I have errors on two different styles.xml files in two folders named Values-v11 and values-v14.
the styles.xml in the Values-v14 folder has an error on the following line...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
the st yles.xml in the Values-v11 folder has an error on ...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
My other projects, that all target 2.33 don't even have these folders. What is the best way of me getting out of this mess?
Thanks, Gary

You could simply delete these folders if you don't want anything specific for SDK level 11, and the one for 14 won't be used anyway if your targetsdk is 11.
If you want to retain the one for api level 11 for custom behaviour in API level 11, you need to set the project to compile with API level 11 - i.e. if in Eclipse, select the project, go to Properties, select Android and then set the project build target to "Android 3.0" or "Google APIs" for API level 11 if you need the Google APIs.

Related

Difference between styles.xml (res\values\styles.xml) and styles.xml (res\values-v21\styles.xml)?

What is the main difference between these two files : styles.xml (res\values\styles.xml) and styles.xml (res\values-v21\styles.xml ?
For targeting old android versions, which file should we modify?
Android will use res\values-v21\styles.xml if the user's device is running Android API level 21+ (Android 5.0+) & will use res\values\styles.xml for older versions
It just means that the styles differ in android versions.
styles.xml in values-v21 mean that, that particular style is for Android API 21 version 5.0+
while styles.xml will be for any other Android version besides 5.0+.
its the same as language where you create an activity for en, fr, pk etc.
Older version would automatically be targetted by the values/styles.xml file.

Style in values-v11 and values-v14

I wonder what would happen if i write some code in the file style.xml in the folder values-v14 and when this is executed in a device than not use this api 14, would happen in that case ?
I am new in this language of android..
Thank for your time...
It's worth indicating that i.e. values-v14 will be used for
API 14 and higher, unless there's another folder that got higher
version i.e. on API 14 and higher, content of values-v14 will be
used.
it will not be selected at all for versions below API 14
For more info you may see at
Styles and themes on values, values-v11 and values-v14 folders

confusing about android minSDK

I have a question about minSDK. I took a project example in here: Contacts Providers.
This project has a minSDK = 5. And in styles.xml some attribute which require higher sdk version like:
android:textAllCaps --> min 14
android:fontFamily --> min 16
But that project so no any error and run fine.
When I copy some style into my styles.xml in my project. It causes an error:
android:textAllCaps requires API level 14 (current min is 11)
...
Can someone help me with the compile error?
You can use those styles in the respective minSDK version by using resource qualifiers. In your resource directory: there is base styles, add folders to res/styles-v14 (for use in ice-cream sandwich and greater, where minSDK is 14) and styles-v16 (so on so forth if you need the styles to be applied when available)
Now when the style needs a higher SDK version, place it in respective style resource directory. textAllCaps goes into styles-v14, android:fontFamily goes into styles-v16.
More can be found here on resource qualifiers ;)
http://developer.android.com/guide/topics/resources/providing-resources.html
Hope this helps buddy, happy coding!
EDIT: previously misunderstood the question/scenario. Sorry!
I think the problem is your Target API level. Make sure that the target api level is at least the level in which the APIs were introduced. In this case, 14.
If you build from command line you would just do
android update project -p -t
(I think what the command does is just update project.properties and sets target=android-14)

No resource found that matches the given name 'android:Theme.Holo.Light'

I have created a project with following settings for Target :
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
But following error persists at values-v11 and values-v14:
ERROR : No resource found that matches the given name 'android:Theme.Holo.Light'
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Assuming you're using Eclipse, you need to right-click your project in the Package Explorer, select Properties, select Android, and set Project Build Target to API level 14 or higher. Or equivalently, set target=android-14 or higher in your project's project.properties file, but note that this file is autogenerated by Eclipse, so manually editing it is not recommended.
First there is problem in the parent attribute, you have to use parent="android:style/Theme.Holo.Light"
Second, Since Holo Theme was introduced in API level 14... so you have to change your android:minSdkVersion="8" to android:minSdkVersion="11", On newer versions it will automatically use Holo theme. You can further read about Holo Theme at
On Android Developers Blog
on Developers.Android.com
However if you want to support previous versions of Android for Holo Themes. You can use Holoeverywhere library.
TextAppearance.Holo.Widget.ActionBar.Title appears to have been added in API Level 13. Make sure your build target is set to 13, not just 11.
AndroidManifest.xml:
<uses-sdk
android:minSdkVersion=...
android:targetSdkVersion="11" />
you can Click Properties of this project and click Android,chose Target Name byond you aim project.

Using different resource files depending of the SDK API level (using Eclipse)?

I am writing an Android app, targeting API levels 8 to 14. I want to use the Theme.Holo.Light theme for API level 11 and higher, and a Theme.Light theme for lower API levels.
The content of res/values/style.xml is:
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
and the content of res/values-v11/style.xml is:
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light" />
</resources>
This compiles well for API level 14, but when setting my target API level to 8, it gives the following error: "Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'" in res/values-v11/style.xml, and "Android AAPT Problem".
If I remove the file res/values-v11/style.xml, the app compiles correctly for API level 8 target.
Now, my understanding is that when compiling for API level 8 the build system should ignore anything inside a resource folder whose name ends with "-v11".
What am I doing wrong?
It's because API 8 got no clue what Theme.Holo.Light is as it was introduced in API11. You have to compile against highest API version you use elements of.
And you understand resource selectors wrong. It's is not used for build the app conditionally. It's used to pick up right resource at runtime.
See this article.

Categories

Resources