2017-01-11 10 views
0
Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (25.1.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details. 

これは、アプリケーションのビルド中に発生したエラーです。以下は私のbuild.gradleファイルです。アンドロイドプロジェクトの構築中に競合依存エラーが発生する

apply plugin: 'com.android.application' 

    android { 
      compileSdkVersion 25 
      buildToolsVersion "25.0.2" 
      defaultConfig { 
          applicationId "com.example.sanket.loginapp" 
          minSdkVersion 18 
          targetSdkVersion 25 
          versionCode 1 
          versionName "1.0" 
          testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     } 
    } 

dependencies { 

compile fileTree(dir: 'libs', include: ['*.jar']) 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') { 
    exclude module: 'support-annotations' 
} 
androidTestCompile 'com.android.support.test:runner:0.5' 
androidTestCompile 'com.android.support.test:rules:0.5' 
androidTestCompile 'com.android.support.test:testing-support-lib:0.1' 
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') 
     { 
      exclude module: 'support-annotations' 
      exclude module: 'support-v4' 
      exclude module: 'support-v13' 
      exclude module: 'recyclerview-v7' 
      exclude module: 'appcompat-v7' 
     } 
androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2') 
     { 
      exclude module: 'support-annotations' 
     } 
androidTestCompile ('com.android.support.test.espresso:espresso-intents:2.2.2') { 
    exclude module: 'support-annotations' 
} 
androidTestCompile ('com.android.support.test.uiautomator:uiautomator-v18:2.1.2'){ 
    exclude module: 'support-annotations' 
} 
compile 'com.android.support:appcompat-v7:25.1.0' 
testCompile 'junit:junit:4.12' 
} 

これは私のbuild.gradleファイルです。私はフォーラムで提供された答えをたくさん試しました。何も働いていないようです。誰かがそれで私を助けることができますか?

答えて

0

この行を追加して、あなたのandroidtestcompileを更新:

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

またはこのようなすべてのespressoモジュール用support-library除いてみてください:

androidTestCompile ('com.android.support.test:runner:0.5') { 
    exclude group: 'com.android.support' 
} 
+0

はまだ動作しません。同じエラーが再度来る – sanketprabhune

0

Resolved versions for app (22.0.0) and test app (21.0.3) differ

を参照してください。

https://blog.mindorks.com/avoiding-conflicts-in-android-gradle-dependencies-28e4200ca235#.hih8d864v

あなたは依存関係ツリーをチェクする

./gradlew dependencies 

を使用することができます。

そして、あなたは問題がサポート-anotationsの下位バージョンを持っている

com.android.support.test:runner:0.5 
com.android.support.test:rules:0.5 
com.android.support.test:rules:0.5 

であることがわかります。

だから、ちょうどそのモジュールでそれを除外:

androidTestCompile ('com.android.support.test:runner:0.5') { 
     exclude module: 'support-annotations' 
} 
androidTestCompile ('com.android.support.test:rules:0.5') { 
    exclude module: 'support-annotations' 
} 
androidTestCompile ('com.android.support.test:rules:0.5') { 
    exclude module: 'support-annotations' 
} 
+0

ねえ、これも動作していません。本当にこれで何が起こっているのか分かりません。他のアプリケーションではこの修正が働いていました。しかし、このために、それは動作していません – sanketprabhune

関連する問題