Reputation: 3481
I need features from Android API-level 11 but if I set targetSdkVersion to 10 then I get the old-style menus that I want (with the menu button). Are these values "legal" to set, or does targetSdkVersion have to be higher or equal to minSdkVersion?
(Note: It seems to work!)
Upvotes: 3
Views: 2443
Reputation: 11873
Always make the targetSdkVersion
greater than equal to the minSdkVersion
.
You can bypass the android:targetSdkVersion
version and use feature for a specific API level. Best way to solve the issue would be programatically determine the device version at runtime and go for the API specific implementation rather than specifying a hard coded value.
See here,
// Make sure we're running on Honeycomb or higher
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// set the new menu styles
} else {
// do nothing and it will show the default theme
}
Check the official documentation here,
http://developer.android.com/training/basics/supporting-devices/platforms.html#version-codes
Upvotes: 0
Reputation: 15414
As the document says about the android:targetSdkVersion
,
An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion. This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).
In anycase,targetSdkVersion
should always be greater than or equal to the minSdkVersion
, because in no way can your app run below minSdkVersion
. If you have put targetSdkVersion
less than the minSdkVersion
that means you are telling the android system that you have tested this app on the targetSdkVersion
, but this is not possible (since your app can run on devices only as low as minSdkVersion
).
Hence by contradiction targetSdkVersion
should always be greater than equal to the minSdkVersion
.
Upvotes: 4