I already have an android app which supports pre-lollipop devices , but I want to port the android app to support both latest versions up to Marshmallow and early versions up to Jellybean ,Is there any specific guidelines available to support above criteria ?
Asked
Active
Viewed 38 times
1
-
"I want to port the android app to support both latest versions up to Marshmallow" -- what are you trying to do? did you test your app on Marshmallow? it may be working already – Anton Malyshev Aug 27 '16 at 11:07
2 Answers
2
In your manifest/build.gradle:(depending on what you use)
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
Gradle:
defaultConfig {
........
minSdkVersion 14
targetSdkVersion 23
}
Set the minSDK to as low as possible. If it is too low, it will show an error. Remember that if you are using any code that requires higher API levels(e.g. when writing xml only writing android:layout_marginStart
that requires API 17) you get an error telling you to increase min API level. Now, there are some ways to avoid increasing;
- If possible, add code that also supports lower API levels(e.g.
android:layout_marginRight
- Aim your code at lower API levels if no alternatives are available for supporting both.
- Remember the OS distribution and target the platforms with the highest percentage. No need to target practically dead platforms.
- You can run old code on new devices, however new code on old devices is either not possible or requires AppCompat(e.g. material design)
- Even though I say run old code to target old and new platforms, avoid deprecated code! If possible, use AppCompat to use new code on old devices.
To summarize:
When coding XML, use code that supports old and new(if available). When doing normal coding, attempt to use code that supports older versions and new that aren't deprecated. If possible use AppCompat to get new code and new things on old devices.

Zoe
- 27,060
- 21
- 118
- 148
-
"Set the minSDK to as low as possible. If it is too low, it will show an error. " -- not always, sometimes it's just a warning, sometimes you can receive crash in runtime – Anton Malyshev Aug 27 '16 at 11:05
-
It varies. But in my experience, when running a gradle build with too low min sdk version the code that requires higher will cause an error durring the build – Zoe Aug 27 '16 at 11:23
-
-
the main point is you find(in some or another way) that the min SDK is too low. Either warning crash or gradle build. – Zoe Aug 27 '16 at 11:29
1
You can change your support version from gradle file like this
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1"
multiDexEnabled true
}

h_patel
- 744
- 5
- 16