I plan on creating an application for users to view their stats of a game I am currently in the process of making but my question is like the title. I am not sure if phones with Android 3.0, Android 2.0 or lower can use the apps? If not, how would I work around this? Would I just not be able to use the new API features such as NFC etc? All in all, if I start developing with Android 4.0 SDK, will all android phones be able to use my app?
3 Answers
My understanding of android development, is that you can build against a lowest common denominator if you build a single package, and it will run on that version, and most likely any newer version. But not the other way around.

- 8,873
- 1
- 26
- 34
The compatibility library (which we're now just calling the support library) doesn't use any special magic to pull this off. You can check Build.VERSION.SDK_INT
at runtime and use classloader guarantees to access newer functionality when it's available. Some examples are here: http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html
We recommend taking a graduated approach to supporting different platform versions. Provide a simpler version of your UI on older versions and layer features on top as they become available. The link above gives some examples of how to do this, and we're going to continue expanding the support library with more *Compat
classes that do the version checking for you when using newer features that may or may not be available on all devices you want to support.

- 28,862
- 9
- 81
- 69
-
So with this library, should I begin building on Android 4.0 SDK and then add in the Support Library to support the other Android API levels? – Snwspeckle Oct 20 '11 at 20:50
-
2The library is just an implementation of some of the described techniques. Yes, you should build with the newest SDK available. Set minSdkVersion in your manifest to the lowest version you plan to support, set targetSdkVersion to the newest version you plan to support, and ensure that any time you use a newer API that you are certain you're running on a device that actually has it. :) – adamp Oct 20 '11 at 21:18
-
1Ok so I do not need to add in the library to my workspace to support for lower API levels? Sorry for these novice questions, I am new to Android and I want to make sure I start correctly so I will not have long term issues. – Snwspeckle Oct 20 '11 at 21:58
-
It's alright. :) The support library has a bunch of useful tools that you may want to use, but no, it's not needed to support lower API levels. The only thing you *need* to do to support older devices is set `minSdkVersion` appropriately in your manifest and be sure you don't try to use or call something that won't exist on those older devices. – adamp Oct 20 '11 at 22:02
-
Oh ok so the latest SDK's have the Support for lower level API's built in but to initiate them we just need to set the versions to what we want to support. Thanks man for the help! Kudos to you! – Snwspeckle Oct 20 '11 at 22:33
-
Every new API level is a strict superset of the one that came before it. Any API available for an older version of the platform will be present on a newer version. To put it another way, API 14 includes API 1-13. – adamp Oct 20 '11 at 22:58
-
One more question, I just downloaded the newest SDK. When I launch the Android SDK manager, do I need to download and install all the version of Android I want to be able to support for my apps? For example if I want to support Android 2.2, do I need install it or not since Android 4.0 already supports everything below it? – Snwspeckle Oct 21 '11 at 00:01
-
1Just the Android 4.0 version should be fine. – adamp Oct 21 '11 at 00:36
Chris is right. However this can be limiting. What if you want to be flexible and use features of the 3.0 and 4.0 android in you app if the device you're running on has them and then gracefully fallback if they don't? Enter the android compatibility package. You can do development using really old api's (all the way back to 1.6) and still have access to new api features.

- 30,445
- 13
- 78
- 102