support package
支持的最低版本的api版本是4.
support package 包含静态的support 库,通过将这个库添加到android application 中我们便可以使用那些不适用于旧版本的或者是那些提供的实用的但不属于框架的api。目的就是通过捆绑更多的api到application中来简化开发,同时可以使你话费更少的精力在平台的版本问题上。
note:support package 包含不止一个的support library每一个都有一个不同的支持的最低版本的api版本,例如一个库要求api版本是四或者更高,同时另一个库要求api版本是13或者更高(V13是V4的一个超集,包含了额外的支持V13api的类),最低版本通过名字来表示如V4 V13。
在google最新的sdk文档中我们能看到最新版本support package 的修订。
以下摘录自google的官方文档,告诉大家怎么下载support package 以及如何将support library 加入到自己的工程中来,英文很容易懂,就不翻译了。
Downloading the Support Package
The Support Package is provided as a downloadable package from the Android SDK and AVD Manager. To install:
- Launch the SDK and AVD Manager.
From Eclipse, you can select Window > Android SDK and AVD Manager. Or, launch
SDK Manager.exe
from the<sdk>/
directory (on Windows only) orandroid
from the<sdk>/tools/
directory. - Expand the Android Repository, check Android Support package and click Install selected.
- Proceed to install the package.
When done, all files (including source code, samples, and the .jar
files) are saved into the <sdk>/extras/android/support/
directory. This directory contains each of the different support libraries, such as the library for API level 4 and up and the library for API level 13 and up, each named with the respective version (such as v4/
).
Setting Up a Project to Use a Library
To add one of the libraries to your Android project:
- In your Android project, create a directory named
libs
at the root of your project (next tosrc/
,res/
, etc.) - Locate the JAR file for the library you want to use and copy it into the
libs/
directory.For example, the library that supports API level 4 and up is located at
<sdk>/extras/android/support/v4/android-support-v4.jar
. - Add the JAR to your project build path.
In Eclipse, right-click the JAR file in the Package Explorer, select Build Path > Add to Build Path. You should then see the JAR file appear in a new directory called Referenced Libraries.
Your application is now ready to use the library APIs. All the provided APIs are available in the android.support
package (for example, android.support.v4
).