人们说它们是相同的,但它们在developer site
中所述的不同情况下使用1 - 添加没有资源的库
To add a Support Library without resources to your application project:
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a libs/ directory in the root of your application project.
Copy the JAR file from your Android SDK installation directory (e.g., <sdk>/extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory.
2 - 用资源添加库
To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a library project and ensure the required JAR files are included in the project's build path:
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to <sdk>/extras/android/support/v7/appcompat/.
Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
Right-click the library project folder and select Build Path > Configure Build Path.
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
Uncheck Android Dependencies.
Click OK to complete the changes.
You now have a library project for your selected Support Library that you can use with one or more application projects.
何时应该使用appcompat_v7(自动生成项目) 什么时候使用android-support-v7-appcompat?
在哪种情况下,程序员需要在库中添加资源?
请用你的经验喂我
答案 0 :(得分:2)
android-support-v7-appcompat.jar
是一个JAR文件,仅包含已编译的Java类。 appcompat_v7
是一个库项目,它包含以前的JAR文件,没有实际的源代码,以及许多资源(布局,图像和&amp; c)。
在appcompat-v7
的特定情况下,您需要才能使用图书馆计划,因为它包含必要的用户界面资源。
其他库(例如v7 MediaRouter或v7 Palette)不包含这些资源,因此可以直接使用JAR文件。
请注意,差异主要适用于Eclipse(其中包含资源的库必须作为项目导入,而其他库只能放在libs文件夹中)。使用Android Studio / gradle,这全部由构建系统处理,因此两者的过程相同。 Support Library Setup文档中对此进行了详细解释。
答案 1 :(得分:0)
生成的appcompat_v7包含android-support-v7-appcompat库以及一些资源。如果让Eclipse生成主题和布局,他们将引用appcompat_v7项目中的资源,如果没有它,您的项目将无法构建。我从未遇到过只需要没有资源的库的情况,但如果您想将新的支持库功能合并到现有项目中,也许可能会这样。