support-v4传递依赖被添加了两次。您可以使用依赖项任务或依赖项洞察报告来验证它:
MacBook-Pro:demo alex$ ./gradlew app:dependencies --configuration compile
或者:
MacBook-Pro:demo alex$ ./gradlew app:dependencyInsight --configuration compile --dependency support-v4
其中demo是项目的根目录。编译配置的输出将是:
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:21.0.0
| \--- com.android.support:support-v4:21.0.0
| \--- com.android.support:support-annotations:21.0.0
\--- com.wu-man:android-oauth-client:0.0.3
+--- com.google.oauth-client:google-oauth-client-java6:1.15.0-rc
| \--- com.google.oauth-client:google-oauth-client:1.15.0-rc
| +--- com.google.http-client:google-http-client:1.15.0-rc
| | \--- com.google.code.findbugs:jsr305:1.3.9
| \--- com.google.code.findbugs:jsr305:1.3.9
+--- com.google.http-client:google-http-client-jackson:1.15.0-rc
| +--- com.google.http-client:google-http-client:1.15.0-rc (*)
| \--- org.codehaus.jackson:jackson-core-asl:1.9.11
+--- com.google.android:support-v4:r7
\--- com.google.api-client:google-api-client-android:1.15.0-rc
+--- com.google.api-client:google-api-client:1.15.0-rc
| \--- com.google.oauth-client:google-oauth-client:1.15.0-rc (*)
\--- com.google.http-client:google-http-client-android:1.15.0-rc
\--- com.google.http-client:google-http-client:1.15.0-rc (*)
依赖洞察报告的输出将是:
:app:dependencyInsight
com.android.support:support-v4:21.0.0
\--- com.android.support:appcompat-v7:21.0.0
\--- compile
com.google.android:support-v4:r7
\--- com.wu-man:android-oauth-client:0.0.3
\--- compile
请注意,appcompat-v7和android-oauth-client都依赖于support-v4。您可以通过排除 android-oauth-client 的依赖项轻松解决它:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile ('com.wu-man:android-oauth-client:0.0.3') {
exclude group: 'com.google.android', module: 'support-v4'
}
}