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
Related
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
I'm trying to change the theme of an app that I'm trying to develop using Android Studio. Apparently, there are at least two ways to do so: by editing the styles.xml file and by using the button above the preview (for me it's the middle button stating the name of the selected theme).
What I'm witnessing is this: When I try to change the theme by using the button, it will update the preview. When I edit the styles.xml file, neither the button caption nor the preview change. And when I run the application, neither the theme chosen using the button nor the theme specified in the styles.xml file are used.
So for example, I have chosen "Material Dark" using the button and specified Holo Light in styles.xml like so without the two interfering with each other at all:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
And then, when I finally run the app in an emulator, I don't even know the theme (light gray action bar, black text color) that it displays the app in but it's not one that I have specified.
That being said, (almost) every other change I apply to the app in any way using Android Studio is displayed just fine both in the preview and in the emulator. An exception to that rule is the changing of the text color of the elements through the activity's XML file...
I'd appreciate any help, since I'm at my wit's end and also somewhat new to the whole thing.
Thanks! - koala
This is because ide sees no emulator. Emulator always run, but ide could hang up in state "Waiting for target device to come online".
Possible reason - Android API versions mismatch. Check if minSdkVersion and targetSdkVersion in Gradle Scripts - build.gradle (Module: app) correspond device API (also Synch push Synch Project with Gradle Files on a panel). Also low versions (e.g. API 15) result in ide-emulator link failure, inspite of application and device versions match.
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
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.
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.