Error Conflict with dependency com.android.support support-annotations

Android

違う担当者のPCのAndroid Studioで、同じプロジェクトを読み込もうとしたところ、下記のエラーが出て、どうしてもビルドできませんでした。

Error:Conflict with dependency ‘com.android.support:support-annotations’. Resolved versions for app (23.0.0) and test app (23.1.1) differ.

ちなみに、問題のあったappのbuild.gradleは次のような感じ

下記のようなサイトを見て、

http://stackoverflow.com/questions/36833606/android-support-library-error-after-updating-to-23-3-0

 androidTestCompile 'com.android.support:support-annotations:23.0.1'

 androidTestCompile 'com.android.support:support-annotations:23.1.1'

に直して、Syncをやり直しても、どうにも同じエラーしか出ません。。。

♪なんでんなんでんなんでやねんねんねん!

そこで、stack oveflowさんの記事で、dependencyを調べてみよ!というアドバイスもありましたので、なんかイヤだな~と思いながらやってみます。

Android StudioのTerminal から

 gradlew -q app:dependencies

とやります。
すると、下記のようにdependencyがわーっと出てきます。ひゃっほーい!!

 Microsoft Windows [Version 10.0.10586]
 (c) 2015 Microsoft Corporation. All rights reserved.
 
 C:\Android\hogehoge>gradlew :app:dependencies
 Incremental java compilation is an incubating feature.                           
 WARNING: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
 :app:dependencies                
                                  
 ------------------------------------------------------------
 Project :app                     
 ------------------------------------------------------------
                                 
 _debugAndroidTestApk - ## Internal use, do not manually configure ##
 +--- com.android.support:support-annotations:23.0.1 -> 23.1.1
 +--- com.android.support.test:runner:0.5
 |    +--- com.android.support:support-annotations:23.1.1
 |    +--- junit:junit:4.12       
 |    |    \--- org.hamcrest:hamcrest-core:1.3
 |    \--- com.android.support.test:exposed-instrumentation-api-publish:0.5
 +--- com.android.support.test:rules:0.5
 |    \--- com.android.support.test:runner:0.5 (*)
 +--- org.hamcrest:hamcrest-library:1.3
 |    \--- org.hamcrest:hamcrest-core:1.3
 +--- com.android.support.test.espresso:espresso-core:2.2.2
 |    +--- com.squareup:javawriter:2.1.1
 |    +--- com.android.support.test:rules:0.5 (*)
 |    +--- com.android.support.test:runner:0.5 (*)
 |    +--- javax.inject:javax.inject:1
 |    +--- org.hamcrest:hamcrest-library:1.3 (*)
 |    +--- com.android.support.test.espresso:espresso-idling-resource:2.2.2
 |    +--- org.hamcrest:hamcrest-integration:1.3
 |    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
 |    +--- com.google.code.findbugs:jsr305:2.0.1
 |    \--- javax.annotation:javax.annotation-api:1.2
 +--- com.android.support.test.uiautomator:uiautomator-v18:2.1.1
 \--- com.android.support.test.espresso:espresso-intents:2.2.2
     \--- com.android.support.test.espresso:espresso-core:2.2.2 (*)
                                 
 _debugAndroidTestCompile - ## Internal use, do not manually configure ##
 +--- com.android.support:support-annotations:23.0.1 -> 23.1.1
 +--- com.android.support.test:runner:0.5
 |    +--- com.android.support:support-annotations:23.1.1
 |    +--- junit:junit:4.12       
 |    |    \--- org.hamcrest:hamcrest-core:1.3
 |    \--- com.android.support.test:exposed-instrumentation-api-publish:0.5
 +--- com.android.support.test:rules:0.5
 |    \--- com.android.support.test:runner:0.5 (*)
 +--- org.hamcrest:hamcrest-library:1.3
 |    \--- org.hamcrest:hamcrest-core:1.3
 +--- com.android.support.test.espresso:espresso-core:2.2.2
 |    +--- com.squareup:javawriter:2.1.1
 |    +--- com.android.support.test:rules:0.5 (*)
 |    +--- com.android.support.test:runner:0.5 (*)
 |    +--- javax.inject:javax.inject:1
 |    +--- org.hamcrest:hamcrest-library:1.3 (*)
 |    +--- com.android.support.test.espresso:espresso-idling-resource:2.2.2
 |    +--- org.hamcrest:hamcrest-integration:1.3
 |    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
 |    +--- com.google.code.findbugs:jsr305:2.0.1
 |    \--- javax.annotation:javax.annotation-api:1.2
 +--- com.android.support.test.uiautomator:uiautomator-v18:2.1.1
 \--- com.android.support.test.espresso:espresso-intents:2.2.2
      \--- com.android.support.test.espresso:espresso-core:2.2.2 (*)
                                 
 _debugApk - ## Internal use, do not manually configure ##
 +--- com.facebook.android:facebook-android-sdk:4.6.0
 |    +--- com.parse.bolts:bolts-android:1.2.0
 |    \--- com.android.support:support-v4:[22,23) -> 23.0.0
 |         \--- com.android.support:support-annotations:23.0.0
 +--- com.google.android.gms:play-services-gcm:8.4.0
 |    +--- com.google.android.gms:play-services-base:8.4.0
 |    |    \--- com.google.android.gms:play-services-basement:8.4.0
 |    |         \--- com.android.support:support-v4:23.0.0 (*)
 |    \--- com.google.android.gms:play-services-measurement:8.4.0
 |         \--- com.google.android.gms:play-services-basement:8.4.0 (*)
 +--- org.apache.httpcomponents:httpcore:4.4.1
 +--- com.android.support.test.espresso:espresso-idling-resource:2.2.2
 \--- com.google.android.gms:play-services-measurement:8.4.0 (*)
                                 
 _debugCompile - ## Internal use, do not manually configure ##
 +--- com.facebook.android:facebook-android-sdk:4.6.0
 |    +--- com.parse.bolts:bolts-android:1.2.0
 |    \--- com.android.support:support-v4:[22,23) -> 23.0.0
 |         \--- com.android.support:support-annotations:23.0.0
 +--- com.google.android.gms:play-services-gcm:8.4.0
 |    +--- com.google.android.gms:play-services-base:8.4.0
 |    |    \--- com.google.android.gms:play-services-basement:8.4.0
 |    |         \--- com.android.support:support-v4:23.0.0 (*)
 |    \--- com.google.android.gms:play-services-measurement:8.4.0
 |         \--- com.google.android.gms:play-services-basement:8.4.0 (*)
 +--- org.apache.httpcomponents:httpcore:4.4.1
 +--- com.android.support.test.espresso:espresso-idling-resource:2.2.2
 \--- com.google.android.gms:play-services-measurement:8.4.0 (*)
                                  
 //あとは略

そう、謎は解けまして、

 +--- com.facebook.android:facebook-android-sdk:4.6.0
 |    +--- com.parse.bolts:bolts-android:1.2.0
 |    \--- com.android.support:support-v4:[22,23) -> 23.0.0
 |         \--- com.android.support:support-annotations:23.0.0

でFacebookのライブラリが、com.android.support:support-annotations:23.0.0を使ってるんですね!

なるー…。

Facebookのライブラリの指定を

 compile 'com.facebook.android:facebook-android-sdk:4.+'

に変更しsupport-annotationsも下記のように

 androidTestCompile 'com.android.support:support-annotations:23.4.0'

で、解決できました!

やはり、みなさんがやった方がいいということはやった方がいい、という教訓ですね[smile]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です