As I\'m importing an existing Android project into Eclipse, I am asked to select an SDK build target as part of the process.
Why do I need to enter this information?
Here is a description of each attribute, exactly what it controls, and how you should use it.
In AndroidManifest.xml:
midSdkVersion: Used by the Google Play Market. The lowest API on which you will allow your app to run. Devices running a version of Android older than this will not be allowed to install your app. Set this to the lowest version of android that your code can support (i.e. it doesn't use any API calls newer than this without paying special attention to backward compatibility). Of course, you should test on a device or emulator running this version.
Google provides a dashboard giving you a breakdown of the number of people using each version, which can be useful when deciding whether it's OK to stop supporting one.
Note: If you are using any of the android-support libraries, you should not use an older version than indicated in the name of the support library. For example, android-support-v4.jar will not run on versions of Android older than 4.
targetSdkVersion: Used by devices at run time. Devices use this to decide whether to run your app in a backward compatibility mode. For example, if you set this to 10 (Gingerbread) devices that run 16 (Jelly Bean) will still use the visual styling of Gingerbread for your app; e.g. it will have a title bar instead of an action bar. Set this to the newest version of Android that you want your app to look like (which you can only determine by testing it on newer versions to see if it looks good and behaves well).
In project.properties, or set via Eclipse's Project Build Target setting:
target: Used by your computer at compile time. The version of Android that your app is compiled against. Trying to use API features newer than this will cause an error. You should set this to the same as minSdkVersion unless you do special things for backward compatibility (see below), so that the compiler will prevent you from accidentally using features that don't exist on your users' older devices (causing it to crash).
Note: It is possible for library projects you include to require a minimum for this value. For example, android-support-v7-appcompat includes .xml resource files in res/layout-v14 that require you to compile against API 14 or newer.
A note on backward compatibility:
There is a case when project.properties should be higher than minSdkVersion: when you want to use newer API features, but you include special code for backward compatibility to allow it to run on older devices. In this case you will have to bump project.properties up to the match the oldest API that contains all the features you use.
When possible, use the Android Support Libraries to accomplish backward compatibility, because it is conventional, well tested, easy, and allows you to leave project.properties alone. However, sometimes the support libraries do not meet your needs, in which case you will have to use techniques such as this or these