Android L: Compatibility With Previous Android Versions - android

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

Related

Values folders for specific android versions

I'm just starting to get into material design for android and I ran into small problem - material design guide says to create separate values-v21 folder and create my custom theme there, while all older versions will fall back to default values folder. By the time tutorial was released 21 Android version was the latest, so do I need separate folders for each subsequent android versions (22,23..) now and just copy same theme? Or will all later version will fall back to v21 theme if there's no newer version values folder?
No. Only create a /values/ and a /values-v21/ folder for your styles. This will be used by Android 5 and below and Android 6 and above.
If both folders exist with proper Styles.xml files, then Android 6 devices will use values-v21 and Android 5 and below devices will use values

Classes could not be instantiated: Android Studio Rendering Problems API 22

Whenever I create a blank activity layout file assigned to be rendered at API level 22, following error message is generated
The solution to this is to change the API level by changing it to API 21 or less.
What is the reason behind this?.
This was very common for me when a new API SDK version was released and yes like you mention we have to change the Android version to use when rendering layout in the IDE.
But this time i have installed all the elements described in the Android SDK Manager for this API 22 and I have no problems with the rendering.
You can just change "AppTheme" to another theme and keep the API level as you desire.
Many users are reporting this problem and it happens only in the Layout files that uses support libraries and not the normal ones.

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

Can't import ActionBar in Android App with backwards compatibility

I have an Android application that targets API 17 and has a minimum SDK version of 8. I'm not interested in providing the ActionBar in devices with Android API < 11, but I'd like to use in the devices running Android >= 3.0.
Browsing stackoverflow in order to learn how to do so, I stumbled upon this question: How to code backward compatible new feature in Android SDK?. I wanted to use the implementation provided in its answer, but I can't import android.app.ActionBar. Eclipse would not recognise it.
What could be the problem? Thanks in advance.
Make sure that your project is referencing the android.jar file for the target, rather than the minimum SDK.
In eclipse, right click project -> Build Path -> Configure Build Path, and see which Android version is referenced there.
Why not use action bar sherlock ?
As mentioned here
Beginning with Android 3.0 (API level 11), the action bar appears at
the top of an activity's window when the activity uses the system's
Holo theme (or one of its descendant themes), which is the default.
You may otherwise add the action bar by calling
requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom
theme with the windowActionBar property.

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