1

After updating android studio, I tried to run a project, but it show me an error because of some dependency error, saying that there is a Conflict with dependency 'com.android.support:support-annotations'.

This my build.gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
defaultConfig {
    applicationId "com.example.abdelnacer.parentooandroid"
    minSdkVersion 21
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
}


repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots"     } 
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
compile 'com.parse:parseui-widget-android:0.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
testCompile 'org.mockito:mockito-core:1.+'
testCompile 'org.robolectric:robolectric:3.2-SNAPSHOT'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
androidTestCompile 'com.android.support:support-annotations:24.2.1'
compile 'com.google.guava:guava:19.0'
compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.wefika:flowlayout:0.4.1'
compile 'com.facebook.shimmer:shimmer:0.1.0@aar'
compile 'com.github.armcha:LuseenBottomNavigation:1.8.2'
}

and the error

Information:Gradle tasks [:app:generateDebugSources,    :app:generateDebugAndroidTestSources, :app:mockableAndroidJar,  :app:prepareDebugUnitTestDependencies]
Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (25.0.0) and test app (24.2.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
> Dependency Error. See console for details.

I really can't figure out what's the problem?

Abdennacer Lachiheb
  • 4,388
  • 7
  • 30
  • 61
  • If you look at the error, it has: "See http://g.co/androidstudio/app-test-app-conflict for details." If you visit the page mentioned in the error, you get an explanation of the problem. And, if you search on `com.android.support:support-annotations conflict` on major search engines, you will come up with answers [like this one](http://stackoverflow.com/a/33318482/115145). – CommonsWare Oct 30 '16 at 15:45
  • 2
    one of your libraries is importing annotations version 25.0.0. Run `./ gradlew dependencies` to see which one in the dependency tree – njzk2 Oct 30 '16 at 15:49

2 Answers2

1

add:

 androidTestCompile "com.android.support:support-annotations:25.0.0"
ligi
  • 39,001
  • 44
  • 144
  • 244
  • the op is using v24.2.1 for all other support libraries. – njzk2 Oct 30 '16 at 15:48
  • no - see his stacktrace - one lib is pullig in 25.0.0 - so he gets: Resolved versions for app (25.0.0) and test app (24.2.1) differ. – ligi Oct 30 '16 at 16:00
  • all support libraries should use the same version.`compile 'com.android.support:appcompat-v7:24.2.1'` all `com.android.support` libraries should be using the same version. if you change to 25.0.0, you should change the version for all `com.android.support` libraries. – njzk2 Oct 30 '16 at 16:58
  • @njzk2 i didn't change version for the com.android.support libraries, and it's work for now, is it dangerous? – Abdennacer Lachiheb Oct 30 '16 at 17:15
  • 1
    @AbdenaceurLichiheb a little. There might be some incompatibilities between the libraries, as they all depend on each other. – njzk2 Oct 30 '16 at 17:20
0

Maybe one of your lib, use this dependency. Just install API 25 and update everything in SDK Manager.

Piotr Badura
  • 1,574
  • 1
  • 13
  • 17