Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Execution failed for task ':app:preDebugAndroidTestBuild' , when tried to run java program in android studio

Tags:

java

android

Getting the below error at the time of running java program in android studio.

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.

Any solution please. ?

like image 241
Kms Avatar asked Apr 29 '18 17:04

Kms


4 Answers

Use implementation 'com.android.support:appcompat-v7:27.1.1' instead of implementation 'com.android.support:appcompat-v7:26.1.0' and change compileSdkVersion 26 to 27

like image 189
Nazmus Saadat Avatar answered Oct 11 '22 08:10

Nazmus Saadat


thanks to @Ganesh Bhat and Chad Bingham

For those who still facing the problem, above answer did not help me in android studio 2.2 Preview.

This fixed my issue.

add this to your gradle file.

configurations.all {
  resolutionStrategy {
    force 'com.android.support:support-annotations:23.1.1'
 }
}

Reference: https://github.com/JakeWharton/u2020/blob/05a57bf43b9b61f16d32cbe8717af77cd608b0fb/build.gradle#L136-L140

Android support library error after updating to 23.3.0

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


update - if the previous answer doesn't work :

you should update the compileSdkVersion and appcompat to the latest update till now compileSdkVersion is 27 , also appcompat is 27.1.1 and 28.0.0-alpha1 is a pre-release version

thus

change

compileSdkVersion 27

the attached photo will help you

and

implementation 'com.android.support:appcompat-v7:26.1.0'

to latest update

implementation 'com.android.support:appcompat-v7:27.1.1'

you can check the latest updates from this link :

https://developer.android.com/topic/libraries/support-library/revisions

like image 38
mahmoud zaher Avatar answered Oct 11 '22 09:10

mahmoud zaher


I answered before some minutes same question Reference. If you are not going to implement testing code, then remove junit from your app.

There are lot of other questions related to this.

Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.1.1) differ

Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ

like image 32
Khemraj Sharma Avatar answered Oct 11 '22 09:10

Khemraj Sharma


Add this to your app gradle file

configurations.all {
   resolutionStrategy {
      force 'com.android.support:support-annotations:26.1.0'
   }
}
like image 25
Mohammed mansoor Avatar answered Oct 11 '22 09:10

Mohammed mansoor