关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题
问题描述:
使用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:
以上是个人解决问题过程中查阅一些资料得出的一些结论,可能会有不对的地方,希望有看出问题的仁兄指点一二。刚开始学习Android开发,有些知识实现太薄弱,为了记录下平时遇到的一些问题,也只好先将自己理解的一些东西写出来,等对Android多熟悉一些,再回来检查下这些文章吧<( ̄︶ ̄)>
关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题的更多相关文章
- 【转】关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题
问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_v7_ ...
- Android开发中遇到的问题(三)——eclipse创建android项目无法正常预览布局文件
一.问题描述 今天使用SDK Manager将Android SDK的版本更新到了Android 5.1的版本,eclipse创建android项目时,预览activity_main.xml文件时提示 ...
- 使用eclipse创建android项目的时候为什么会生成两个项目
使用eclipse创建android项目的时候为什么会生成两个项目 问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创 ...
- 创建Android项目时出错——No resource found that matches the given name 'Theme.AppCompat.Light'
创建Android项目时出错,error: Error retrieving parent for item: No resource found that matches the given nam ...
- eclipse 创建 maven 项目时如何修改 web 的版本和 jdk 的版本
eclipse 创建 maven 项目时如何修改 web 的版本和 jdk 的版本 在使用 eclipse 创建 maven 项目的时候,默认的 web.xml 的版本时 2.3,默认 jre 的版本 ...
- eclipse创建android项目失败的问题 [ android support library ]
有根筋搭错了,想起来android应用开发???? 放下两年的手机应用开发,昨天有更新了android SDK, 重新搭建开发环境. 这两年android 变化真TM的大............... ...
- Eclipse创建新项目时无法输入项目名的解决方法
放假耍了那么久,也是该收心忙活了. 今天打开Eclipse新建项目时,发生了一个很奇怪的情况,就是在下面这个位置的输入框无法输入. 经过百度之后,发现解决方案是(原地址点我) Eclipse图标右键 ...
- 使用Eclipse创建Web项目时WEB-INF下找不到web.xml问题详解
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/yjrguxing/article/deta ...
- 关于eclipse创建java项目时产生的.settings文件:
在用eclipse创建一个java项目,在项目目录下面往往会发现.settings文件夹并包含一个org.eclipse.core.resources.prefs文件条目. 这个条目是配置项目的编码方 ...
随机推荐
- python 单例模式获取IP代理
python 单例模式获取IP代理 tags:python python单例模式 python获取ip代理 引言:最近在学习python,先说一下我学Python得原因,一个是因为它足够好用,完成同样 ...
- sshpass笔记
sshpass简介 ssh登录的时候使用的是交互式输入,不能预先在命令行使用参数指定密码,sshpass就是为了解决这个问题的.sshpass提供非交互式输入密码的方式,可以用在shell脚本中自动输 ...
- Protobuf3语法详解
定义一个消息类型 先来看一个非常简单的例子.假设你想定义一个"搜索请求"的消息格式,每一个请求含有一个查询字符串.你感兴趣的查询结果所在的页数,以及每一页多少条查询结果.可以采用如 ...
- [self init]
在字典转模型中遇到了这样的代码: #import "HMAppInfo.h" @implementation HMAppInfo - (instancetype)initWithD ...
- PHP MySQL 插入数据
PHP MySQL 插入数据 使用 MySQLi 和 PDO 向 MySQL 插入数据 在创建完数据库和表后,我们可以向表中添加数据. 以下为一些语法规则: PHP 中 SQL 查询语句必须使用引号 ...
- Docker内核能力机制
能力机制(Capability)是 Linux 内核一个强大的特性,可以提供细粒度的权限访问控制. Linux 内核自 2.2 版本起就支持能力机制,它将权限划分为更加细粒度的操作能力,既可以作用在进 ...
- Redis从入门到精通:中级篇
原文链接:http://www.cnblogs.com/xrq730/p/8944539.html,转载请注明出处,谢谢 本文目录 上一篇文章以认识Redis为主,写了Redis系列的第一篇,现在开启 ...
- git 撤销没有提交的变化
参考: https://stackoverflow.com/questions/5807137/how-to-revert-uncommitted-changes-including-files-an ...
- Android仅2步实现 滚粗 汉堡导航栏效果~ 全新底部导航交互(滑动隐藏)
本文同步自wing的地方酒馆 布吉岛大家有木有看这一篇文章,再见,汉堡菜单,我们有了新的 Android 交互设计方案 本库下载地址:https://github.com/githubwing/Bye ...
- [Angular2]eclipse中angular2开发环境的搭建
本文作者:苏生米沿 本文地址:http://blog.csdn.net/sushengmiyan 环境准备 1.eclipse neon 2.网络连接 插件地址 eclipse的插件市场地址: htt ...