Trying to follow the tutorial here: https://developer.android.com/training/basics/firstapp/creating-project
but after I create an activity and click "Finish" it gives a Gradle build error saying:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
Looking at other SO solutions (the second answer here: Resolved versions for app (22.0.0) and test app (21.0.3) differ) it said to add this to the dependencies on build.gradle script:
androidTestCompile 'com.android.support:support-annotations:xx.x.x'
The above solution is also what it shows on Google Samples (https://github.com/googlesamples/android-testing/blob/ba14ef9e925fa17621bf86abe5336dcb9d53e466/runner/AndroidJunitRunnerSample/app/build.gradle#L36)
So this is now my build.gradle (Module: app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ahmedayman.ember"
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestCompile 'com.android.support:support-annotations:26.1.0'
}
but I'm still getting the same error when I try to sync the project. Any idea how to solve this?