原文地址:http://developer.android.com/tools/support-library/setup.html
如何在你的开发项目中安装Android Support Library,取决于你要使用哪些功能,以及你要在你的应用中支持哪个范围的Android平台版本。
原文:How you setup the Android Support Libraries in your development project depends on what features you want to use and what range of Android platform versions you want to support with your application.
这个文档指导你下载Support Library包,并向你的开发环境中添加库。
原文:This document guides you through downloading the Support Library package and adding libraries to your development environment.
Android Support Library包是作为Android SDK的补充下载提供的,并且在AndroidSDK Manager中是可用的。遵循以下说明来获取Support Library文件。
原文:The Android Support Library package is provided as a supplemental download to the Android SDK and is available through the Android SDK Manager. Follow the instructions below to obtain the Support Library files.
通过SDK Manager获取Support Library:
1.打开Android SDK Manager
2.在SDK Manager窗口,滚动到Package List的末尾,找到Extra文件夹,如果需要的话打开文件夹显示它的内容。
3.选择Android Support Library项目。
注意:如果你使用的是Android Studio开发,选择并安装Android Support Repository项目而不是Android Support Library项目。
4.点击Install packages按钮。
下载完成后,SDK会将Support Library文件安装到你已经存在的Android SDK目录下。库文件位于SDK的如下子目录:<sdk>/extras/android/support/目录。
原文:After downloading, the tool installs the Support Library files to your existing Android SDK directory. The library files are located in the following subdirectory of your SDK: <sdk>/extras/android/support/
directory.
原文:In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment. You must perform this procedure for each Support Library you want to use.
除了可编译的代码类,一些Support Library包含了资源,比如图片或XML文件。例如,v7 appcompat和 v7 gridlayout库包含一些资源。
原文:Some Support Libraries contain resources beyond compiled code classes, such as images or XML files. For example, thev7 appcompat and v7 gridlayout libraries include resources.
如果你不确定一个库是否包含资源,查看Support Library Features页面。下面的章节描述了如何添加一个包含或不包含资源的Support Library到你的应用项目中。
原文:If you are not sure if a library contains resources, check the Support Library Features page. The following sections describe how to add a Support Library with or without resources to your application project.
原文:To add a Support Library without resources to your application project:
对目前framework API提供支持的Support Library类,一般都与framework中的类名相同,但是位于android.support类包中,或者有一个*Compat后缀。
原文:Support Library classes that provide support for existing framework APIs typically have the same name as framework class but are located in the android.support
class packages, or have a *Compat
suffix.
警告:当使用Support Library中的类的时候,确定你从适当的包中引入这些类。例如,当应用ActionBar类的时候:
原文:Caution: When using classes from the Support Library, be certain you import the class from the appropriate package. For example, when applying the ActionBar
class:
android.support.v7.app.ActionBar
when using the Support Library.android.app.ActionBar
when developing only for API level 11 or higher.原文:Note: After including the Support Library in your application project, we strongly recommend using the ProGuard tool to prepare your application APK for release. In addition to protecting your source code, the ProGuard tool also removes unused classes from any libraries you include in your application, which keeps the download size of your application as small as possible. For more information, see ProGuard.
在Android开发者training classes、guides和示例中,提供了一些使用Support Library功能的更多指南。查看API参考中的android.support包,以获取更多关于单个Support Library类和方法的信息。
原文:Further guidance for using some Support Library features is provided in the Android developer training classes, guides and samples. For more information about the individual Support Library classes and methods, see the android.support
packages in the API reference.
<uses-sdk>标签的
android:minSdkVersion元素,改成一个新的,更低的版本号,如下:
android:minSdkVersion
element of the <uses-sdk>
tag in the manifest to the new, lower version number, as shown below:原文:This change tells Google Play that your application can be installed on devices with Android 2.1 (API level 7) and higher.
注意:如果你在项目中包含了v4 support和v7 appcompat库,你需要指定最小SDK版本为7(而不是4)。你引入到应用的最高级别的support library决定了它可以操作的最低的API版本。(译者注:这句话是指当你同时引入了多个包的情况,比如,v7比v4版本更高,所以可以操作的最小SDK版本是7)
"7"
(and not
"4"
). The highest support library level you include in your application determines the lowest API version in which it can operate.
<sdk>/extras/android/support/samples/Support4Demos/
<sdk>/extras/android/support/samples/Support7Demos/
<sdk>/extras/android/support/samples/Support13Demos/
<sdk>/extras/android/support/samples/SupportAppNavigation/