Saturday, August 28, 2010

How Do You Know Which Android API To Develop Against

If you are building any Android Applications you already know that you must declare a http://schemas.android.com/apk/res/android:uses-sdk@android:minSdkVersion in your application, like this in XML:

    <uses-sdk android:minSdkVersion="3" />

But how do you know which version to use?  Heck, how do you even know what version your current application code supports?

Google says to just keep backing it off until you find a bug:

Selecting a platform version and API Level

When you are developing your application, you will need to choose the platform version against which you will compile the application. In general, you should compile your application against the lowest possible version of the platform that your application can support.

You can determine the lowest possible platform version by compiling the application against successively lower build targets. After you determine the lowest version, you should create an AVD using the corresponding platform version (and API Level) and fully test your application. Make sure to declare a android:minSdkVersion attribute in the application's manifest and set its value to the API Level of the platform version.



Google also maintains a very, very useful resource here that shows the current state of the Android ecosystem (or as some people call it, fragmentation!)

Basically the idea is, declare an absolute bare minimum in your Android manifest so you can penetrate the market as much as possible.

I am using minSdkVersion = 3, but I can see 4 being another logical choice.  If you are minSdkVersion=7 you must have a really good reason -- like you are using some API7 and above only features. 

Otherwise, you are just missing out on customers.

No comments: