I have been using android support v4 23.1.1 and recently tried to update it to 23.3.0 ( the latest one when this was asked) but I got the following error:
Just exemplifying Akshayraj's answer
Original Gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
[...]
compile 'com.android.support:support-annotations:25.3.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}
Received error:
Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'.
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. "
FIXED when I added:
androidTestCompile 'com.android.support:support-annotations:25.3.0'
Final File:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
[...]
compile 'com.android.support:support-annotations:25.3.0'
androidTestCompile 'com.android.support:support-annotations:25.3.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}
Just exclude 'annotations'. No harm will be done
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Took me a while to get out of this error. But this is what has worked for me, give it a try:
NOTE: Am using compileSdkVersion 26
I removed both androidTestImplementation 'com.android.support.test:runner:1.0.2' & androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' in the dependencies block in build.gradle(Module: app). So I ended up with this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.date.brian.cradletest"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.getbase:floatingactionbutton:1.9.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
testImplementation 'junit:junit:4.12'
}
I hope this comes in handy!
For those who still facing the problem, above answer did not help me in android studio 2.2 Preview.
add this to your gradle file.
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.1.1'
}
}
This fixed my issue.
Reference: https://github.com/JakeWharton/u2020/blob/05a57bf43b9b61f16d32cbe8717af77cd608b0fb/build.gradle#L136-L140
compile 'com.android.support:design:24.1.1'
For me, The build tool version has to align with the dependency versions. So lets say the build tool version is 26.1.0, the Gradle dependency version has to obey it.
The simplest way is to create a version variable & use it. See the example below
ext {
buildVersion = '26.1.0'
}
dependencies {
compile "com.android.support:appcompat-v7:${buildVersion}"
}