Error in Values v11-v14 styles After change API - android

I have been building my app in 4.2.2 and when I try to change the API level to 2.3.3 it gives me a error in vaules v11,v14. I want to change it to 2.3.3 so It can work for more phones models.
<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>
Can anyone tell me how to fix this error and tell me how it happen.

You only need to change the minimum API to work with Android 2.3 and leave target API as it was, e.g. to support 2.3 at the minimum and target 4.4, you should use:
android:minSdkVersion="9"
android:targetSdkVersion="19"
You should also build against Android 4.4 in this case.
Application will be available for devices with Android 2.3 but you will obviously need to make sure it works on them.

Related

Feature requires API "21" or higher, but still works on lower

I used this style:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Primary theme color of the app (sets background color of app bar) -->
<item name="colorPrimary">#FF9800</item>
<!-- Background color of buttons in the app -->
<item name="colorButtonNormal">#FF9800</item>
</style>
I copy-pasted this from some tutorial, and the teacher said that "colorButtonNormal" wont work in API lower than 21. I went to developer.android.com to do a research and that was correct. But i started app, and it is fully functional on my Xperia X8 which is API 9, the buttons are truly orange, just like that hex color code. Can someone explain to me what is really happening there. And what really bothers me, is that Android Studio never warned me that I am using features that requires API higher than my minimum selected (which is 9). I used the Analyze->Inspect Code, no warnings about that..
Now I'm confused, is there something i can do, so i can see if i'm using some features that requires higher API than my minimum.
Because you declared it as Theme.AppCompat.Light and it will be compatible with older versions of android
Read this guide

Changing the min. SDK version of an Android app 2

I work withe android open source Bluetooth project & I like to use Holo theme series but sdk min version is 6 when I change this version to higher version in my test device return error :unfortunately , app name has stopped
here is my source url : https://github.com/polyclef/BluetoothChatMulti
excuse Because of my bad English
In newer versions of Android, the framework will use the Window.FEATURE_ACTION_BAR feature whenever the Holo theme is selected.
The framework throws the exception whenever an app calls setFeatureInt(Window.FEATURE_CUSTOM_TITLE) and FEATURE_ACTION_BAR has already been set.
In my case, the styles.xml file in the values-v11 folder was redefining my theme to inherit from android:Theme.Holo. When I attempted to run my app on a Android 3.0 or above - it crashed because Holo uses the ActionBar by default. The fix was simple. Turn the ActionBar off when using Holo. Here is the revised values-v11\styles.xml changes:
<style name="AppBaseTheme" parent="android:Theme.Holo.NoActionBar">
<!-- API 11 theme customizations can go here. -->
</style>
and for higer versions we can't combine custom titles or other title features

Using Android L Material Design on KitKat

Reading the Compatibility section of Android L Developer Preview (http://developer.android.com/preview/material/compatibility.html) I've seen that i can create an APP using L-sdk and also be able to run it on older sdk (like KitKat).
I've created a new project using Android L sdk and configured "build.gradle" as said in this post: Android Studio : Failure [INSTALL_FAILED_OLDER_SDK].
I've tried both the configurations:
the one proposed in question that gives me this error:
pkg: /data/local/tmp/com.example.{my user name}.materialapp
Failure [INSTALL_FAILED_OLDER_SDK]
and the one proposed in answer that gives me error on
<style name="AppTheme" parent="android:Theme.Material.Light"></style>
I've searched on others question on StackOverflow but I can't find no solutions.
SOLUTION:
Android L preview material style can be used only on devices that run Android L.
The "compatibility" is only a preview and it's not enabled.
You have to create 2 different styles.xml files with the same name that you will put in different folders.
The first, will go here:
res/styles.xml
and will look NOT have a reference to the Material theme (use the Holo theme):
so would have something like this:
<style name="AppTheme" parent="android:Theme.Holo.Light"></style>
The second will go here:
res/values-v21/styles.xml
and WILL contain the reference to the new Material theme, and would have:
<style name="AppTheme" parent="android:Theme.Material.Light"></style>
The Android framework will automatically use the correct one depending on which API the device supports (so on API 21 devices it will use Material, and on all other devices, it will use whatever else you define).
This has changed since the original answer, as Google released better support for Material design in the AppCompat libraries (which support mostly all versions of Android).
At this point, you should be using these libraries for all development, then you will be able to support Material design related features in all your apps.
Here is how to set it up: https://developer.android.com/topic/libraries/support-library/setup.html

Android: Theme.Holo is not black

I am developing my new Android App and after I made the first layouts, I was wondering why everything is white (background) and not black like always before. So I figured out it is because of Theme.Holo.Light.DarkActionBar. I immediately changed it to Theme.Holo but nothing changed in the Emulator.
I googled the problem and they said that your minSDK has to be 11+, so I changed it to 11,12,13,14 but nothing changed again!
What can I do to see the old and nice black theme?
The values-v11 and values-v14 folders have styles.xml files in them that need to be updated in addition to the main one.
Use Theme.Holo. Since you elected not to post any source code, it is impossible to indicate where you are going wrong. However, if you run an app using a theme based upon Theme.Holo -- such as this sample app -- you get a dark background.
The easiest way to get Theme.Holo is to not specify a theme at all, as Theme.Holo is the default for apps with android:targetSdkVersion of 11 or higher and running on an API Level 11+ device.
The sample app I linked to takes a more elaborate approach, courtesy of Eclipse's code generators:
It has res/values/styles.xml defining AppTheme as inheriting from the old dark Theme:
It has res/values/styles.xml defining AppTheme as inheriting from Theme.Holo:
It uses AppTheme in its manifest (which for some reason is not displaying in this answer, so you will have to settle for clicking the link)
Hence, it will use Theme.Holo on API Level 11+ devices and Theme on older devices. Both supply a dark background.

Android ActionBarSherlock - How can I change a theme for API <3.0 and the same on API >=3.0

I did a new theme on my app, that the parent is Theme.Sherlock.Light. On devices with API <3.0 the changes are working, but when the app is running on devices >=3.0 (in this case is 4.0.3) my new Style isn't working, still using the original Theme.Sherlock.Light.
How can I make an xml style that affects the style in a device with API <3.0 and the same on the devices >=3.0?
With ActionBarSherlock, you need to declare your styles twice: once with, and once without the android:-prefix.
See the examples here: http://actionbarsherlock.com/theming.html

Categories

Resources