Reputation: 627
I have defined in my manifest android:targetSdkVersion="15"
and I would like to test with a device with API level
equal to 17
.
The minSdkVersion
is set to 15.
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
I know it will work since minSdkVersion is set to a lower version than the device's one but my question is should I change the targetVersion whenever I change the device ? Isn't the targetSdkVersion
supposed to be always equal to the one of the device I am testing with as it is said in the reference
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html ?
Upvotes: 0
Views: 170
Reputation: 382
You shouldn't change the target version with every device, but with every new API level that is released.
As the webpage that you've already posted states:
As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect.
and a few lines further:
To maintain your application along with each Android release, you should increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.
Every new API contains new features, but will also deprecate old ones; some may even get removed completely! So devices running with a higher API level might not support the same features anymore that you used in your app, which forces them to enable compatibility mode to once again be able to run the app properly.
In short, no, your targetSdkVersion
should just be as high as the highest API goes. The minSdkVersion
should of course be as low as possible, and you should try to avoid using maxSdkVersion
, as that one will decrease the mobility of your app over time.
Even if your minSdkVersion
is 1 and the targetSdkVersion
is 19, new devices won't have to enable compatibility mode to run the app.
Upvotes: 2