Khursand Shakeel Khursand Shakeel - 4 months ago 42
Android Question

Choosing SDK version to reach maximum number of people

I am a complete beginner in Android Development and just downloaded Android SDK to integrate it with Eclipse.

However, I don't know which Android version I should select in SDK Manager to allow a maximum number of people to download and use my app.

Here's a screenshot of the manager that is showing up on my screen.

SDK Manager window

Any kind of help would be really appreciated.
Thanks.

Answer

In fact, you don't need to download an OLD SDK just to allow OLD Devices to use your app.

This is done in your project settings via target SDK version and min API level(AndroidManifest.xml or build.gradle).

Define Audience

First, define the audience to your app.

HERE you can find the market share for every Android Version (this can change for each country but it may help).

If you check that table, you can see that only few devices are still using API 15 or older.

enter image description here

So, if you support API<15, you will only reach ~3% more people. If you can support them without lose any feature, good (not all android features are supported/ported to all versions). But if you may need to disable a feature (like that special Floating Action Button that you created) just to reach those devices, I think it does not worth.

So, based on that table, you define the audience

In my case for example, I like to build apps for devices with API from API_16 to API_24.

Usually, we always want to use maximum API available. Today, 24.

This way, I could reach ~97% of the people using Android.

But this is optional... I could select min API as 13... or 14.. or 4.. This is up to you..

After defining the audience

Target SDK

I usually set the target API according to the MAX API I want to support. So, for example, if the MAX API I want to support is API_24, this will be my target API and will download the SDK v24 (7.0).

Usually, you always will have the latest SDK installed since you always want to reach latest android version and enjoy all the new features.

MIN API

Now, you also have defined the min API version that you want to support. So, lets use API 16 for example (first JB version).

You will set this in your project file (AndroidManifest.xml). You don't need to download SDK 16 just because of that.

Setting Eclipse

As I said, min SDK will be set in your project. That would be done in your Android Manifest

Here, you can see that targetSdk is 24. It means that I just need to download SDK v24 to build this project. Even then, I'll be able to install this App in devices with API 16 or later.

Eclipse (AndroidManifest.xml)

<manifest>
    ....
    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="24" />
    ...
</manifest>

Android Studio (build.gradle)

compileSdkVersion 24
buildToolsVersion "24.0.0"

minSdkVersion "16"
targetSdkVersion "24"

minSdkVersion Does Not Guarantee that your app will work

Note that settings above only allow your app to run in devices with API>=16 or API<=24. However, your app may crash or does not work in all devices within that range. This usually happens because some View Components or Methods were added or removed according to API version.

For example, Fragment was added only on API11. So, if you try to install your app in a phone with APIv11, it will work. However, if you install it in a device with API4, it will crash.

Another example is method Fragment.onAttach(Context context) which was added only in API 23.

That's why we use Support Library

Support Design Library it is a library created by Google which enables the developer to use features from new Android Versions in old Android versions.

So, for example, to add a Fragment which is compatible with devices with API<11, you should import and use Fragment class from package android.support.v4.app.Fragment instead of default version included in SDK (android.app.Fragment).

This way, your app wont crash.

Of course this is very basic example. It is just to illustrate...

Anyway, I hope I could help you Regards

Comments