targetSdkVersion

关于 <uses-sdk>

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#considerations

问题:

  1. 什么是targetSdkVersion
  2. targetSdkVersion有什么用

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.

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 continue to work the way you expect.

There are many compatibility behaviors that the system may enable based on the value you set for this attribute.Serveral of thess behaviors are described by the corresponding platform version in the Build.VERSION_CODE reference.

To maintain your application along with each Android release,you should increase the value of this attribute to match the lastest API level,then thoroughly test your application on the corresponding platform version.(完全看不懂这啥意思啊,为啥我要把targetSdkVersion搞成最新的API level啊,to maintain your application along with each Android relase啥意思啊.)

What is API level?

API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.

The framework API consists of:

  • A core set of packages and classes
  • A set of XML elements and attributes for declaring a manifest file
  • A set of Intents
  • A set of permissions that applications can request,as well as permision enforcements included in the system

Android和API Level的对应关系

Platrom Version

API Level

VERSON_CODE

Android 6.0

23

M

Android 5.1

22

LOLLIPOP_MR1

Android 5.0

21

LOLLIPOP

Android 4.4W

20

KITKAT_WATCH

Android 4.4

19

KITKAT

Android 4.3

18

JELLY_BEAN_MR2

Android 4.2,4.2.2

17

JELLY_BEAN_MR1

Android 4.1,4.1.1

16

JELLY_BEAN

Android 4.0.3,4.0.4

15

ICE_CREAM_SANDWICH_MR1

Android 4.0,4.0.1,4.0.2

14

ICE_CREAM_SANDWICH

评论

暂无评论