在AndroidMenifest.xml中,經常會有下面的語句:html
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="10" android:maxSdkVersion="15" />
在project.properties中,會看到下面的語句: target=android-10 若是是使用Eclipse的話,還可能會看到這樣的警告:java
Attribute minSdkVersion (4) is lower than the project target API level (10)
那麼,這裏面的minSdkVersion、maxSdkVersion、targetSdkVersion、target四個屬性到底有什麼區別?android
project.properties中的target是指在編譯的時候使用哪一個版本的API進行編譯。 綜上,上面的四個值實際上是做用於不一樣的時期:測試
這四個數值在程序編譯時也沒有嚴格的檢查,好比說,你能夠將minSdkVersion設置的比maxSdkVersion還大,會自動忽略掉錯誤的maxSdkVersion。this
android:targetSdkVersion
minSdkVersion
.
This attribute informs the system that you have tested against the target version and thesystem should not enable any compatibility behaviors to maintain your app's forward-compatibilitywith the target version. The application is still able to run on older versions (down to minSdkVersion
).spa
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 appcontinues to work the way you expect. You can disable such compatibilitybehaviors by specifying targetSdkVersion
to match the APIlevel of the platform on which it's running. For example, setting this value to "11" or higherallows the system to apply a new default theme (Holo) to your app when running on Android 3.0 orhigher and also disables screencompatibility mode when running on larger screens (because support for API level 11 implicitlysupports larger screens).code
There are many compatibility behaviors that the system may enable based on the value you setfor this attribute. Several of these behaviors are described by the corresponding platform versionsin the Build.VERSION_CODES
reference.
To maintain your application along with each Android release, you should increasethe value of this attribute to match the latest API level, then thoroughly test your application onthe corresponding platform version.
Introduced in: API Level 4
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html