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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With