What is the difference between targetSdkVersion set in the Manifest file and the Project build target set in the building environment (e.g. Eclipse) ?
I have tried to find more information on these two features, but I couldn’t find any clear and specific explanation.
It seems like the Project build target decides on the API compatibility level, to be used during the compilation. When the targetSdkVersion only affects the visibility of the manifest elements of the given API level.
Could anyone confirm/expound this?
EDIT: Thanks guys for prompt responses. I forgot to mention in my question that I have read all the topics on Android Dev regarding these features and also googled it and searched it on Stack Overflow. So I understand the basic purpose of min/target/maxSdkVersion to be used in Android Market and in the Android System itself. However, according to other posts from people having problems with this Manifest option, it seems uses-sdk does actually have impact on how the the API level is interpreted. At least that is what I suspect.
A really good explanation is given here:
http://developer.android.com/guide/appendix/api-levels.html
However, it is still unclear for me whether the targetSdkVersion does affect the compilation/runtime of the APK on Android System? Or it is only for validation as the uses-sdk documentation suggests?
The
targetSdkVersionattribute does indeed affect an application’s runtime behavior.Depending on what you set it to will determine whether compatibility features are enabled/disabled in the Android framework.
For example, once you set targetSdkVersion=11, your application’s default theme will be set to
@android:style/Theme.Holo— meaning your application will have a Honeycomb-style UI widgets, will get an Action Bar, and will not have an Options Menu button at the bottom of the screen.If you set targetSdkVersion to a lower value than, your default theme will continue to be
@android:style/Theme— regardless of which API level you’re actually building against.The targetSdkLevel also affects what the default values are for the
<supports-screens>element, which in turn will determine whether your application runs in density compatibility mode.Interesting note: Android Market doesn’t actually use the targetSdkLevel attribute for anything at the moment. It’s purely used at runtime for compatibility purposes, and possibly at compile time — though I haven’t looked into the behavior there. If people are curious about the compiler, I could check with the SDK team to get more information.
Of course, it’s entirely possible that Market could decide to do something with this in the future.