domingo, 29 de mayo de 2011

Android target sdk vs min sdk versions

An android project has two important properties in its manifest: target sdk version and min sdk version.  If you use eclipse to develop those properties are requested by the new android project wizard during the setup of the project.  I've never been completely sure of the meaning of both properties and I would try to clarify it in this post for all the people that could face the same doubt in the future.

  • min sdk version is the minimun version required for the application to run.  If the device hasn't an android version equals or bigger than min-sdk version the application can not be installed in the device.
  • target sdk is the version used to build the application binary during development.  This property has two different purpouses or implications:
    • Android APIs that can be used.   If target version is bigger than min-sdk version you can use new APIs supported in versions until target version (always taking care of checking if that feature is supported in the android version where the application is running because it could be running in a min-sdk device not supporting that feature).
    • Android optimizations that will be applied to your application during execution.   You inform android that you have tested your application with target-sdk versions and it hasn't to make under the hoode any optimization intended for old applications.
There is also a max-sdk version property but its use is discouraged in android documentation.

[1] Android Reference: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html