See Google’s official platform distribution.
Android Build Option Matrix
Here’s a table that shows the total accumulated device coverage for each API level. Device coverage should be one of the key factor for picking a target API for Android development.
|Build API||Level||Distribution||Device Coverage|
Note: Base on data available on 8/01/2011.
Base of on the device coverage alone, 2.1 is the best choice to date. Note that platform 1.6 have similar coverage, but lacks the all important “AccountManager” feature.
So is 2.1 the best choices? Are we forced to develop on an API, that is, 7 iterations old? Can we build an app with the latest API and yet able to run on lower API devices?
Yes, there’s a way.
There’s a well known work around among developers, but it’s tricky and must be exercised with care.
If you build an app with a higher level API, you can still deploy that to lower level devices, except that you must not make higher API calls when running on lower API runtime.
In side the app AndroidManifest.xml:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="12"/>
minSdkVersion - Specify min version to be the lowest API you want your app to run with.
targetSdkVersion - Specify the latest api version you want to compile your app with.
When you build the app, go ahead and build with the latest SDK.
Code Workaround Example:
In this example we check the current API level, if it’s greater or equal to 5, we go ahead and call overridePendingTransition, which is only available for API 5+.
However, If this is handled incorrectly, your app will crash. Some variety of runtime exception will be thrown.
A simpler solution is just use a library. AQuery provides an easier way to handler these cross-api-levels calls. It abstract away all the details and make sure the operation fallback gracefully when a feature is not available.
Here are some examples.
Enable hardware acceleration:Set activity transition animation:
Handling cross-api-level calls is just one of the feature available from the open-source AQuery library. Read more about AQuery here.
Any feedback is welcomed!
What aspect of Android development you want us to blog about?
Leave a comment below and subscribe to the blog. :)