Getting the below error at the time of running java program in android studio.
Error:Execution failed for task \':app:preDebugAndroidTestBuild\'.
<its important to take a look at this too, in your gradle
targetSdkVersion 27
compileSdkVersion 27
buildToolsVersion '27.0.3'
AS configuration version:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
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'**
Modify:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.0.0-beta1'
testImplementation 'junit:junit:4.12'
**androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'**
Hello guys I had the same problem for solving this problem u need to change you appcompat in your app bulid gradle to
implementation 'com.android.support:appcompat-v7:27.1.1'
then it should ask you to instal it if u have'nt installed if still errore didnt solved change your sdkversions it will help alot because if u change the appcompact to 27.1.1 u need to change your sdkversion to 27 as well i suggest all of u to update your android studio and the sdk to the lastest
I found this very easy.
We will use update and use same version for all modules.
build.gradle
, use global variables// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlinVersion = '1.2.61'
ext.global_minSdkVersion = 16
ext.global_targetSdkVersion = 28
ext.global_buildToolsVersion = '28.0.1'
ext.global_supportLibVersion = '27.1.1'
}
build.gradle
, and use global variablesapp level build.gradle
android {
compileSdkVersion global_targetSdkVersion
buildToolsVersion global_buildToolsVersion
defaultConfig {
minSdkVersion global_minSdkVersion
targetSdkVersion global_targetSdkVersion
}
...
dependencies {
implementation "com.android.support:appcompat-v7:$global_supportLibVersion"
implementation "com.android.support:recyclerview-v7:$global_supportLibVersion"
// and so on...
}
some library/module build.gradle
android {
compileSdkVersion global_targetSdkVersion
buildToolsVersion global_buildToolsVersion
defaultConfig {
minSdkVersion global_minSdkVersion
targetSdkVersion global_targetSdkVersion
}
...
dependencies {
implementation "com.android.support:appcompat-v7:$global_supportLibVersion"
implementation "com.android.support:recyclerview-v7:$global_supportLibVersion"
// and so on...
}
The solution is to make your versions same as in all modules. So that you don't have conflicts.
I felt when I have updated versions of everything- gradle, sdks, libraries etc. then I face less errors. Because developers are working hard to make it easy development on Android Studio.
Always have **latest but stable versions** Unstable versions are alpha
, beta
and rc
, ignore them in developing.
I have updated all below in my projects, and feel flawless coding.
build.gradle
- classpath 'com.android.tools.build:gradle:3.2.0'
(Track android.build.gradle release & this) buildToolVersion
(Track buildToolVersion release)compileSdkVersion
and targetSdkVersion
Track platform release Happy coding! :)
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
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
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