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
Related
I am not sure what's going on I searched everywhere not what to do. I am trying to change the themes of the app, but only certain themes are available coding
available themes1
available themes2
These are the only themes available if I try using other themes it's causing an error
Use #android:theme/... as follow
I am creating a project that uses a big number of icons, in order to support multiple screens easily, I created the icons using vector graphics (SVG paths I believe they are called) which worked ok in my device.
Unfortunately when I tried to use it on older devices (anything with android less than 5.0) I get an inflater exception.
After searching I found out that in order to use vector graphics for those devices instead of using
android:src
I have to use
app:srcCompat
this indeed fixed the problem, but now when I deploy it to a newer device, the icons won't show (at least it doesn't crash though, so that's something)
Is there a way to define some sort of style to use according to api version
so that I can do something along the lines of :
<style name="android.api.21">
<item name="android:src">ic_menu</item>
</style>
<style name="android.api.19">
<item name="app:srcCompat">ic_menu</item>
</style>
Thanks in advance for any help you can provide
Just use the same style name (for example, styles.xml) and in resources folder (app/main/res) create different folders with naming values (common version), values-v21 (for API 21, Lolipop 5.0), values-v19 (API 19, KitKat 4.4) and so on and so forth.
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
I've taken the basic Hello World app from the SDK examples and have been learning Android by modifying it. Currently I'm trying to change the Theme. I'm testing it on my Nexus 7 running the latest OS and I'm using Eclipse.
In my manifest I have
android:theme="#style/AppBaseTheme"
In values-v11/styles I have
style name="AppBaseTheme" parent="android:Theme.Black
I've tried using Holo and am aware I need to be V11 or higher to do that.
When I try running my app it starts on the tablet and I can see the black background as expected, but before it can draw any components Eclipse goes to debug mode in ActivityThread.performLaunchActivity and then into ZygoteInit$MethodAndArgsCaller.run() before my app dies.
If I use this it's fine:
style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light"
I feel I'm missing something obvious or there's a fundamental part of Themes that I don't understand. I have tried removing the .android/ directory and restarting Eclipse, that fixed a few other issues.
I know the # symbol in this context denotes that it is an inbuilt style by android. Does that mean I have to add something to my app to link in other themes? If so what exactly?
I pushed an update to the Play Store today adding a material design layout for Android L and some other various bug fixes, however, users who are not using Android L are unable to update. When attempting to update the application, they are presented with "Application requires newer SDK version".
I compiled the application with "android-L", my minimum SDK requirement is 14 and my target SDK is "L". I created a new values folder (values-v21), which uses the same theme name as my other values folders for previous versions of Android. However, instead of using Theme.Holo.Light the v21 folder uses:
<style name="AppBaseTheme" parent="#android:style/Theme.Material.Light">
Is there any way that I can implement the material layout for Android L users while keeping compatibility with Android 4.0 - 4.4?
Edit: I was using Android API 20, L Preview support library. Reverting back to 19 breaks compatibility with the material layouts.
No matter what you do in Gradle/Android studios if you set your target to L-Preview it will override your minSDK. As of right now you should not target L-Preview for anything in production. This is why your users are seeing that issue when trying to update, this also means you can't use the Material Themes in production.
You should revert and wait for the full release of L to use the material layouts.
Material Theme
Quote from page:
Note: The material theme is only available in the Android L Developer Preview. For more information, see Compatibility.
L Compatibility