Joe Dugan
Joe Dugan

Reputation: 119

What factors are important in choosing target android OS for development

What do I need to consider before choosing the target android OS for app development?

This is my understanding of how to do it and any clarification would be appreciated:

  1. Determine which OS version is currently in use the most. Look at distribution graphs etc.
  2. Target that version.

that is what I read all the time, but I have some questions.

Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are unique to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.? Consider the reverse situation. If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?

thanks.

Upvotes: 1

Views: 2694

Answers (3)

bricklore
bricklore

Reputation: 4165

have a look at your AndroidManifest.xml
There is a targetSdkVersion and minSdkVersion if you want to support all devices running 2.2 and up then set minSdkVersion to api level 8 (android 2.2)
but in general, its a good practice to develop against the latest api as target (currently API 19, Android 4.4), so you can ensure it will work from your chosen min up to the newest OS api

so if you want to support at least Gingerbread up to KitKat do this in your manifest:

<uses-sdk android:minSdkVersion="9"
    android:targetSdkVersion="19" />

and develop against api 19 :)

Upvotes: 1

Tenfour04
Tenfour04

Reputation: 93779

The target version is the highest version you have tested it on. You should always target the absolute latest if you can. The min version is the lowest version that will be able to install the app.

So in the manifest, you would typically have something like this:

<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" ...

Pick the minSdkVersion based on the features that are absolutely required for your app to function.

So you might wonder what the purpose of targetSdkVersion is. One reason is if your app has some optional features that are in later versions of the SDK. targetSdkVersion will allow you to use those later features, but you will need to protect those method calls with a check against the device's SDK with a call like

if (Build.VERSION.SDK_INT >= 11)
    myMethodThatUsesFeaturesOnlyInHoneycombAndLater();

Another reason is that sometimes the Android team makes changes to some of the defaults in various settings on your classes, but to maintain compatibility for future versions on which you have not tested your app, they keep the old default if your app doesn't claim to target this later version.

For example, after Honeycomb, the menu is supposed to be integrated with the action bar. But old apps that were compiled with earlier SDKs have not been tested with Honeycomb or later, as proved by them having a targetSdkVersion of less than 11, so the OS knows to display the old style menu. Once this developer decides to test their app on a more recent targetSdkVersion, they update the value and the OS can trust that they have tested it on Honeycomb, so it can safely show the new style menu.

Upvotes: 0

FD_
FD_

Reputation: 12919

Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are new to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.?

Only if you don't use APIs that were introduced after the earliest version you want the app to run on.

If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?

Yes. Some functions get deprecated in newer OS versions, but most of them still work in newer releases for keeping compatibility.

I feel the thing to stress here is that Android is backwards compatible, so newer versions will almost be able to run apps developed for older OS versions.

Upvotes: 0

Related Questions