使用eclipse创建android项目的时候为什么会生成两个项目

问题描述:

使用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 的解释:内容如下:

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.

  • 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.

<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多熟悉一些,再回来检查下这些文章吧<( ̄︶ ̄)>

详细介绍请查看全文:https://cnblogs.com/qianzf/

原文博客的链接地址:https://cnblogs.com/qzf/

使用eclipse创建android项目的时候为什么会生成两个项目的更多相关文章

  1. Android开发中遇到的问题(三)——eclipse创建android项目无法正常预览布局文件

    一.问题描述 今天使用SDK Manager将Android SDK的版本更新到了Android 5.1的版本,eclipse创建android项目时,预览activity_main.xml文件时提示 ...

  2. 基于eclipse创建android的helloworld工程

    基于eclipse创建android的helloworld工程 之前用过Android studio感觉很慢,决定采用eclipse来学习Android开发.下面来看是怎么创建的. 选择File--- ...

  3. 同一个tomcat多个项目共享session,一个tomcat两个项目共享sessionId

    同一个tomcat多个项目共享session,一个tomcat两个项目共享sessionId >>>>>>>>>>>>>& ...

  4. eclipse创建android项目失败的问题 [ android support library ]

    有根筋搭错了,想起来android应用开发???? 放下两年的手机应用开发,昨天有更新了android SDK, 重新搭建开发环境. 这两年android 变化真TM的大............... ...

  5. 关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题

     问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_ ...

  6. 【转】关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题

    问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_v7_ ...

  7. 在eclipse创建android project,最后一步点击finish没反应

    在创建android project的时候,到最后一步点击finish没有反应. 本来以为可能是SDK中的Extra下Android Support Library没有安装,后来检查发现Minimum ...

  8. 将应用代码由eclipse导入Android studio的方法NDK-Build和Cmake两种方法(以android_serialport_api为例)

    网上翻了几百篇博客,看了半天,要不就是写的乱七八糟看不懂,要不就是隐藏了一些细节,要不就是实现不了,最后还是在Android官网上看明白了,而且说得有条有理,以后遇到不懂的一定要先翻官网. 参考资料: ...

  9. eclipse创建android项目,无法正常预览布局文件

    http://jingyan.baidu.com/article/d621e8da0e0e052865913fae.html

随机推荐

  1. 使用django + celery + redis 异步发送邮件

    参考:http://blog.csdn.net/Ricky110/article/details/77205291 环境: centos7  +  python3.6.1 + django2.0.1  ...

  2. JSTL-taglib

    JSTL(JSP Standard Tag Lib) 目录: Core Fmt Function SimpleTagSupport(jsp 自定义标签) Tag File Core <%@ ta ...

  3. 键值集合List转换成datatable

    /// <summary> /// 键值集合List转换成datatable /// </summary> /// <param name="data" ...

  4. 从底层谈WebGIS 原理设计与实现(一):开篇

    从底层谈WebGIS 原理设计与实现(一):开篇 作者:naaoveGI…    文章来源:http://www.cnblogs.com/naaoveGIS/    点击数:4773    更新时间: ...

  5. jsonp 原理

    1 json width padding(内填充); 2.计算机文件的属性 并不是以 文件的后缀名确定的,后缀名只是给人看的: 3.script 标签获取数据后 并不能直接使用: 4.尽可能 少声明 ...

  6. spring cloud DashBoard

    1 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring ...

  7. 【OpenPose-Windows】运行OpenposeDemo.exe 如何保存图像运行结果及关节点信息

    跑过很多次openposeDemo了,不管是video.Webcam还是Images,都是运行结果一闪而过,然而我们所要的肯定不是只看一下运行结果就完事的,很多情况下,我们都希望能够把运行结果的图像. ...

  8. mydumper使用

    一.下载安装,打开https://launchpad.net/mydumper #wget https://launchpadlibrarian.net/185032423/mydumper-0.6. ...

  9. 罗伯特•盖洛博士(Dr. Robert Charles Gallo)是世界著名的美国生物医学家,他以共同发现了人类免疫缺陷病毒(HIV)――这一导致获得性免疫缺陷综合症(AIDS)的致病源而闻名于世。

    罗伯特•盖洛 开放分类:各国生物学家|生物学家罗伯特•盖洛博士(Dr. Robert Charles Gallo)是世界著名的美国生物医学家,他以共同发现了人类免疫缺陷病毒(HIV)――这一导致获得性 ...

  10. powerdns

    powerdns http://bbs.51cto.com/thread-880297-1.html https://blog.csdn.net/kepa520/article/details/791 ...