问题描述:
使用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. <wbr>The content is actually<br>
located in libs/android-support-v7-appcompat.jar.<br>
The accompanying resources must also be included in the application.<br></wbr>
字面意思大概可以看出,该项目是一个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,可以查看到该类库项目已被引用进来了
<wbr></wbr>
原因已查明,可以验证一下:
首先创建一个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
找到<wbr><span style="word-wrap:normal; word-break:normal; line-height:20px; background-color:rgb(249,249,249); font-family:roboto,sans-serif; color:rgb(51,51,51)">v7 appcompat library 的解释:内容如下:</span></wbr>
<wbr></wbr>
This library adds support for the<wbr><a target="_blank" href="http://developer.android.com/guide/topics/ui/actionbar.html" style="text-decoration:none; color:rgb(78,121,83)">Action Bar</a><wbr>user interface<wbr><a target="_blank" href="http://developer.android.com/design/patterns/actionbar.html" style="text-decoration:none; color:rgb(78,121,83)">design
pattern</a>.</wbr></wbr></wbr>
Note:<wbr>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.</wbr>
Here are a few of the key classes included in the v7 appcompat library:
-
ActionBar
<wbr>-
Provides an implementation of the action bar<wbr><a target="_blank" href="http://developer.android.com/design/patterns/actionbar.html" style="text-decoration:none; color:rgb(78,121,83)">user interface pattern</a>. For more information on using
the Action Bar, see the<wbr><a target="_blank" href="http://developer.android.com/guide/topics/ui/actionbar.html" style="text-decoration:none; color:rgb(78,121,83)">Action Bar</a><wbr>developer guide.</wbr></wbr></wbr></wbr>
-
ActionBarActivity
<wbr>-
Adds an application activity class that must be used as a base class for activities that uses the Support Library action bar implementation.</wbr>
-
ShareActionProvider
<wbr>-
Adds support for a standardized sharing action (such as email or posting to social applications) that can be included in an action bar.</wbr>
This library is located in the<wbr><code style="line-height:14px; color:rgb(0,102,0); font-size:13px">/extras/android/support/v7/appcompat/</code><wbr>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<wbr><a target="_blank" href="http://developer.android.com/tools/support-library/setup.html#libs-with-res" style="text-decoration:none; color:rgb(78,121,83)">adding libraries
with resources</a>.</wbr></wbr></wbr>
The Gradle build script dependency identifier for this library is as follows:
分享到:
相关推荐
Android support appcompat_v7_24_2 编译通过版本,方便在Eclipse开发过程直接引入包
导入项目缺少 appcompat_v7 时,在ADT中该项目的lib下加载该包即可
eclipse创建android项目,并且添加appcompat_v7兼容包-附件资源
用来解决eclipse没有appcompat_v7工程出现的异常,使用方法详见我的个人博客
2019 Android最新的v7,v4包,包含最新更新控件, 亲测好用。 源码中找出来的,赚点辛苦费,在eclipse上使用的依赖包,其中包括最新的V4和V7包。
appcompat_v7可以解决使用eclipse开发安卓软件的兼容性问题
eclipse报错: android.support.design.widget.Snackbar找不到(需要design项目...Theme.AppCompat.Light找不到(因为需要appcompat_v7 library) Eclipse下使用Android Design Support Library中的控件(比如TabLayout)
android-support-v7-appcompat,使用Eclipse但是没有自动创建的同学,可以拿来用一下。
这个了项目【android-support-v7-appcompat】 里面 包含 R.styleable.AppCompatTheme这个变量,资源很有用,很全面。 这个是 ADT的项目, 好多人都在用 Android Studio了。。。可正常扫描二维码了,识别出来...
2015年末最新的v7库,源码中找出来的,赚点辛苦费,在eclipse上使用的依赖包,其中包括最新的V4和V7包,这个风格是要这2个包支持的,确切的说是V7需要V4的支持
打包好的三个供eclipse版本使用的android-support-v7包,其中【android-support-v7-appcompat_00.0.0_20150325.zip】 不知道是哪个版本的,【android-support-v7-appcompat_23.1.1_20151124.rar】是23.1.1版android...
在eclipse中开发Android应用时,在需要用到appcompat中的资源时,可以引用support-v7-appcompat.jar包,上面的资源包含多个版本的资源,绝对够用。
源码中找出来的,赚点辛苦费,在eclipse上使用的依赖包,其中包括最新的V4和V7包,这个风格是要这2个包支持的,确切的说是V7需要V4的支持
appcompat-v7-26.1.0.jar, Android Studio真是使用不习惯,Eclipse导入jar又是个问题。烦烦烦
android-support-v7包,需要的请拿去。由于现在as都是gradle配置,所以如果eclipse需要jar而不是lib工程时使用
使用adt开发新建一个Android app,选择支持的SDK版本如果小于11(Android3.0)就会报如下错误。 error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'...
创建Android工程时候缺失的支持文件,需要自行导入该文件到libs解决找不到相关包问题,解决在Eclipse开发Android环境等问题。
基于eclipse的安卓项目开发——博学谷 本项目由eclipse编写,版本最低为API21也就是安卓5(4.X),也可改为安卓九,不影响使用 需要导入android-support-v7-appcompat包