问题
I see some examples use compile 'com.android.support:appcompat-v7:21.0.3'
and some show: compile 'com.android.support:support-v7:21.0.3'
What is the difference between these two libraries?
回答1:
v4 support library
This library is designed to be used with Android 1.6 (API level 4) and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities.
v7 appcompat library
This library adds support for the Action Bar user interface design pattern. This library includes support for material design user interface implementations.
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.
Source: https://developer.android.com/tools/support-library/features.html
回答2:
AppCompat (At first ActionBarCompat) started out as a backport of the Android 4.0 ActionBar API for devices running on Gingerbread, providing a common API layer on top of the backported implementation and the framework implementation. AppCompat v21+ delivers an API and feature-set that is up-to-date with Android 5.0 like some material styles and themes as well as some Android 5 components like cardview and palette library.
As you can see AppCompat is mostly about making new android app design concept available in older versions.
Support Library on the other hand tries to provide functionalities of new version of android in older versions like fragments. It also has some useful classes which are not present in any version of android like ViewPager, LruCache and LocalBroadcastManager.
来源:https://stackoverflow.com/questions/30418215/difference-between-support-and-appcompat-support-libraries