支持设计库本身依赖于appcompat-v7和support-v4库.因此,您删除的显式依赖项将作为传递依赖项自动引入.运行./gradlew app:dependencies确认这一点:
_releaseCompile - ## Internal use, do not manually configure ##
+--- com.android.support:design:23.4.0
| +--- com.android.support:recyclerview-v7:23.4.0
| | +--- com.android.support:support-annotations:23.4.0 -> 24.0.0
| | \--- com.android.support:support-v4:23.4.0 -> 24.0.0 (*)
| +--- com.android.support:appcompat-v7:23.4.0 -> 24.0.0
| | +--- com.android.support:support-v4:24.0.0 (*)
| | +--- com.android.support:support-vector-drawable:24.0.0
| | | \--- com.android.support:support-v4:24.0.0 (*)
| | \--- com.android.support:animated-vector-drawable:24.0.0
| | \--- com.android.support:support-vector-drawable:24.0.0 (*)
| \--- com.android.support:support-v4:23.4.0 -> 24.0.0 (*)
在build.gradle文件中明确声明这些依赖项(通常解释链接的答案)通常被认为是good practice:
If your project has direct dependencies on “B” then you should declare “B” as an explicit dependency even if “B” is a transitive dependency of some other explicit dependency “A”. Future versions of “A” may no longer depend on “B”, and updating to one of these versions of “A” would break your build.