Support Library Setup

  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.

  This document guides you through downloading the Support Library package and adding libraries to your development environment.

Downloading the Support Libraries


  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.

  To download the Support Library through the SDK Manager:

  1. Start the Android SDK Manager.
  2. In the SDK Manager window, scroll to the end of the Packages list, find theExtras folder and, if necessary, expand to show its contents.
  3. Select the Android Support Library item.

    Note: If you're developing with Android Studio, select and install the Android Support Repository item instead.

  4. Click the Install packages... button.

      Figure 1. The Android SDK Manager with the Android Support Library selected.

  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.

Choosing Support Libraries


  Before adding a Support Library to your application, decide what features you want to include and the lowest Android versions you want to support. For more information on the features provided by the different libraries, see Support Library Features.

Adding Support Libraries


  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.

  Some Support Libraries contain resources beyond compiled code classes, such as images or XML files. For example, the v7 appcompat and v7 gridlayout libraries include resources.

 保用支援包时要反它们导入项目中,而有些支援包有资源文件,也要把它们导入。如v7 appcompat和 v7 girdlayout就有资源文件

  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.

Adding libraries without resources(无资源文件支援包的导入步骤)

  To add a Support Library without resources to your application project:

  1. Make sure you have downloaded the Android Support Repository using the SDK Manager.
  2. Open the build.gradle file for your application.
  3. Add the support library to the dependencies section. For example, to add the v4 support library, add the following lines:
     dependencies {
    ...
    compile "com.android.support:support-v4:18.0.+"
    }

Adding libraries with resources(有资源文件支援包的导入步骤)

  To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:

  1. Make sure you have downloaded the Android Support Repository using the SDK Manager.
  2. Open the build.gradle file for your application.
  3. Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:
     dependencies {
    ...
    compile "com.android.support:appcompat-v7:18.0.+"
    }

Using Support Library APIs


  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.

 支援包中的类多在android.support中,或以 *Compat 为后缀

  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.

 如果使用了支援包,通常要生成发布版的apk时,要用ProGuard优化,混淆,减少apk的体积。

  Further guidance for using some Support Library features is provided in the Android developer training classesguides and samples. For more information about the individual Support Library classes and methods, see the android.support packages in the API reference.

Manifest Declaration Changes

  If you are increasing the backward compatibility of your existing application to an earlier version of the Android API with the Support Library, make sure to update your application's manifest. Specifically, you should update the android:minSdkVersion element of the <uses-sdk> tag in the manifest to the new, lower version number, as shown below:

<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />

  The manifest setting tells Google Play that your application can be installed on devices with Android 2.1 (API level 7) and higher.

If you are using Gradle build files, the minSdkVersion setting in the build file overrides the manifest settings.

 apply plugin: 'com.android.application'

 android {
... defaultConfig {
minSdkVersion 8
...
}
...
}

  In this case, the build file setting tells Google Play that the default build variant of your application can be installed on devices with Android 2.2 (API level 8) and higher. For more information about build variants, see Build System Overview.

  Note: If you are including the v4 support and v7 appcompat libraries in your application, you should specify a minimum SDK version of "7" (and not "4"). The highest support library level you include in your application determines the lowest API version in which it can operate.

Code Samples(示例的位置)


  Each Support Library includes code samples to help you get started using the support APIs. The code is included in the download from the SDK Manager and is placed inside the Android SDK installation directory, as listed below:

  • 4v Samples: <sdk>/extras/android/support/samples/Support4Demos/
  • 7v Samples: <sdk>/extras/android/support/samples/Support7Demos/
  • 13v Samples: <sdk>/extras/android/support/samples/Support13Demos/
  • App Navigation: <sdk>/extras/android/support/samples/SupportAppNavigation/

Support Library官方教程(3)android studio中导入支援包的更多相关文章

  1. 在Android Studio中导入jar包

    #1 下载jar包文件, #2 拷贝到libs目录下 #3 打开你的build.gradle,在dependencies加入如下代码 dependencies {compile files('libs ...

  2. Support Library官方教程(2)各支援包的特性详介(含表)*

    快速阅读 包名  作用  位置 是否有资源 v4 提供了最多的api <sdk>/extras/android/support/v4/ y Multidex 把DEX文件生成apk < ...

  3. Android Studio中导入第三方库

    之前开发Android都是使用的eclipse,近期因为和外国朋友Timothy一起开发一款应用,他是从WP平台刚切换使用Android的,使用的开发环境时Android Studio,为了便于项目的 ...

  4. Android studio中导入第三方类库

    常常在github上看到一些好用的框架,但是对于一个新手怎样在android studio上导入去总会遇到各种麻烦,索性来研究下第三方类库怎样在android studio上导入. 以我在github ...

  5. Android如何使用so文件和Android studio中导入so

    Android中使用so文件: 做一个PDF阅读的功能,找到一个开源的库,mupdf.下载的是网上编译好的so库,导入到自己项目中的时候一直报错Java.lang.UnsatisfiedLinkErr ...

  6. Support Library官方教程(1)概述

    Support Library The Android Support Library package is a set of code libraries that provide backward ...

  7. 在android studio中导入github下载的工程

    1.从Github中下载工程压缩包,并将其解压到本地 2.修改文件 假设,解压后的文件目录如下: (1)修改配置文件  xx\build.gradle // Top-level build file ...

  8. Android Studio中导入v4,v7和recyclerview-v7包的方法

    概述 Android Studio中新建工程中会默认导入v7的包,即在gradle中默认配置了com.android.support:appcompat-v7:x.x.x的依赖.但是不会默认为我们配置 ...

  9. 关于Android Studio中第三方jar包的Javadoc绑定

    原文地址:http://blog.csdn.net/a739697044/article/details/28116189   现在刚开始从Eclipse转用Android Studio,现在在尝试使 ...

随机推荐

  1. iOS中引用计数内存管理机制分析

    在 iOS 中引用计数是内存的管理方式,虽然在 iOS5 版本中,已经支持了自动引用计数管理模式,但理解它的运行方式有助于我们了解程序的运行原理,有助于 debug 程序. 操作系统的内存管理分成堆和 ...

  2. .NET中如何使用反序列化JSON字符串/序列化泛型对象toJsonStr

    在进行 .NET Web MVC 框架开发的网站程序的时候,我们都会遇到最关键的问题,数据传输.   .NET MVC 4中的ControllerBase类建议我们用ViewBag动态数据字典形式(t ...

  3. KAFKA分布式消息系统

    2015-01-05 大数据平台 Hadoop大数据平台 基本概念 kafka的工作方式和其他MQ基本相同,只是在一些名词命名上有些不同.为了更好的讨论,这里对这些名词做简单解释.通过这些解释应该可以 ...

  4. Ajax 完整教程

    第 1 页 Ajax 简介 Ajax 由 HTML.JavaScript™ 技术.DHTML 和 DOM 组成,这一杰出的方法可以将笨拙的 Web 界面转化成交互性的 Ajax 应用程序.本文的作者是 ...

  5. Xcode8之后 XMPP 重定义问题 Redefinition of module 'dnssd'

    在升级Xcode到8之后,原来的关于XMPP的项目运行报错,错误信息为: Redefinition of module 'dnssd' 系统和XMPP框架同时用到了 'dnssd',大概就是错误的原因 ...

  6. VS2010 配置opencv环境

    大家在使用opencv的时候肯定会面对这样一个问题:根据官网以及大多数教程提供的方法中,似乎每一次新建一个opencv的新项目以后都需要重新再配置"VC++目录"中的"包 ...

  7. failed creating the Direct3d device--debug

    D3DDEVTYPE_REF 使用REF设备,用软件模拟Direct3D API 照理说是为了让电脑能跑本机不能硬件执行的渲染命令的 但我 pDeviceSettings->d3d9.Devic ...

  8. 基于Pre-Train的CNN模型的图像分类实验

    基于Pre-Train的CNN模型的图像分类实验  MatConvNet工具包提供了好几个在imageNet数据库上训练好的CNN模型,可以利用这个训练好的模型提取图像的特征.本文就利用其中的 “im ...

  9. HDU3068 最长回文 Manacher算法

    Manacher算法是O(n)求最长回文子串的算法,其原理很多别的博客都有介绍,代码用的是clj模板里的,写的确实是异常的简洁,现在的我只能理解个大概,下面这个网址的介绍比较接近于这个模板,以后再好好 ...

  10. Struts2 SSH整合框架返回json时,要注意懒加载问题

    返回的这个json对象,要保证它里面的所有属性都已经取出来了(即不是proxy或者是懒加载),否则当struts框架将该对象转化成json数据时,会报出一个no session的错误. 因此你要将该懒 ...