java – appcompat_v7和android-support-v7-appcompat之间的区别?

人们说他们是相同的,但他们在
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?

在这种情况下,程序员需要在项目中添加资源库吗?

请用我的经验喂我

最佳答案 android-support-v7-appcompat.jar是一个JAR文件,只包含已编译的Java类. appcompat_v7是一个库项目,它包含以前的JAR文件,没有实际的源代码,以及许多资源(布局,图像和& c).

在appcompat-v7的特定情况下,您需要使用Library Project,因为它包含必要的UI资源.

其他库(例如v7 MediaRouter或v7 Palette)不包含这些资源,因此可以直接使用JAR文件.

请注意,差异主要适用于Eclipse(其中包含资源的库必须作为项目导入,而其他库只能放在libs文件夹中).使用Android Studio / gradle,这全部由构建系统处理,因此两者的过程相同.这在Support Library Setup文档中得到了很好的解释.

点赞