ADT Bundle下新建安卓项目的同时会新增一个appcompat_v7_n的原因
来源:互联网 发布:excel统计分析软件 编辑:程序博客网 时间:2024/05/18 01:21
转自:u013521089的博客
问题描述:
使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_v7_2,如果再次创建,会以此类推地创建出appcompat_v7_x格式的“多余项目”出来(此情况在ADT升级为22.6.x版本后出现,22.3.x前的版本不会有)
查明原因:
ADT在22.3.x版本前没有出现该情况,升级为22.6.x版本后,才出现该情况,可以猜测是新版本导致。猜测到原因后可以分析下appcompat_v7是用来做什么的,展开appcompat_v7项目,会发现有一个readme.txt文件,双击查看,该文件描述如下:
Library Project including compatibility ActionBar.
This can be used by an Android project to provide
access to ActionBar on applications running on API 7+.
There is technically no source, but the src folder is necessary
to ensure that the build system works. The content is actually
located in libs/android-support-v7-appcompat.jar.
The accompanying resources must also be included in the application.
字面意思大概可以看出,该项目是一个Library Project, 作用是让你的Android Project 在API 7+的sdk版本(即Android2.1版本)可以访问ActionBar的API,ActionBar相当于用户界面的操作栏,具体ActionBar的解释可以参考:http://developer.android.com/guide/topics/ui/actionbar.html。所以从中可以看出多出这个project是为了兼容低版本的sdk,那我们创建的Android项目是如何引用这个类库项目呢?通过右键点击Android项目---->Properties-->Android,可以查看到该类库项目已被引用进来了
原因已查明,可以验证一下:
首先创建一个Android项目,在选择Android版本号的界面,如果选择的最低Android版本的"大版本号”小于编译时采用的Android大版本号时,就需要考虑版本兼容问题,这样子创建出项目后自然就会产生出appcompat_v7这个类库项目出来。具体界面如下图,如果编译时采用4.3版本,选择最低要求版本号为2.x或者3.x时创建出来的项目就会自动创建appcompat_v7支持库。
疑问:
可以不产生appcompat_v7这个类库项目吗?答案是可以的,只要版本号选择时最低要求版本和编译时用的版本选择同一种即可,但不推荐这么干,开发Android程序需要考虑兼容多个版本
补充:
关于Library Project的相关内容,可以通过查看官方文档介绍,具体查看:http://developer.android.com/tools/support-library/features.html#v4
找到 v7 appcompat library 的解释:内容如下:
This library adds support for the Action Bar user interface design pattern.
Note: This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.
Here are a few of the key classes included in the v7 appcompat library:
ActionBar
- Provides an implementation of the action bar user interface pattern. For more information on using the Action Bar, see the Action Bar developer guide.ActionBarActivity
- Adds an application activity class that must be used as a base class for activities that uses the Support Library action bar implementation.ShareActionProvider
- Adds support for a standardized sharing action (such as email or posting to social applications) that can be included in an action bar.
This library is located in the <sdk>/extras/android/support/v7/appcompat/
directory after you download the Android Support Libraries. This library contains user interface resources. To include it in your application project, follow the instructions for adding libraries with resources.
The Gradle build script dependency identifier for this library is as follows:
- ADT Bundle下新建安卓项目的同时会新增一个appcompat_v7_n的原因
- adt-bundle-eclipse下的修改android项目名
- adt-bundle-linux-x86_64-20131030下新建工程提示找不到adb和R.java问题的解决
- ubuntu14.10下adt bundle安装svn一个可运行的方式
- Windows 下使用adt-bundle-windows 启动SDK Manager 时出错闪退的原因和解决办法
- 安卓 ADT-bundle 官方地址
- 【adt更新】更新Adt bundle的网址
- 史上最清晰快捷的mac下新建cocos2dx跨ios安卓项目教程
- mac下的adt-bundle如何配置jre
- 初学adt-bundle的感想
- mac下快速安装安卓开发环境(通过adt-bundle)
- 安卓环境搭建3 (最快速的Android开发环境搭建ADT-Bundle及Hello World)
- adt新建项目出现appcompat_v7依赖的解决办法
- 安卓 新建项目时出现appcompat_v7的问题
- eclipse新建的安卓项目再次打开一堆错误
- 解决 ubuntu 14.04下,eclipse adt-bundle-linux 闪退的问题,最新ADT-23.0.7
- 新建安卓项目
- Eclipse下新建Android项目碰到的一个小问题
- spring mvc中的@PathVariable
- 2009 求数列的和
- 蒋炳楠:2015年9月27日开通了CSDN博客
- hdu 4000 Fruit Ninja(树状数组)
- Hadoop解析--MapReduce
- ADT Bundle下新建安卓项目的同时会新增一个appcompat_v7_n的原因
- HDU 1232--畅通工程【水题,并查集】
- hust 1010 The Minimum Length
- IOS的safari浏览器的电话号码识别功能的禁用
- POJ Cow Sorting 3270【哈希表+置换群】
- UVA540-Team Queue
- Spring MVC之@RequestParam @RequestBody @RequestHeader 等详解
- Oracle PCTFREE PCTUSED FREELIST 讲的明白
- Linux命令行之文件操作