This is the full error-
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.
I know that there are a lot of solutions to this type of answers but I am an absolute beginner in android studio and I couldnt understand those solutions like the command line interface interacting with gradle and so on...
I was looking for a simple solution to this problem if there is. Thanks a lot!
Change all the implementation in your build gradle app For Example.
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-annotations:27.1.1'
Change It all to latest version(27.1.1) and sync the project.
最近我又遇到了这个错误....我只是去构建 - >重建项目,它每次都适合我。
configurations.all{
resolutionStrategy {
force 'com.android.support:support-annotations:26.1.0'
}
}
Modify below line in gradle file.
//From
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//To
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
This is the type of bug that really makes me resent Android Studio.
But anyway, the solution for me was quite simple: Edit the app.iml
and change the com.android.support:support-annotations
version. In this case it's easy to find, simply ctrl+F
and type "27.1.1" (it should be the only hit) and change to your version "26.1.0".
In other words, change it from
<orderEntry type="library" scope="TEST" name="com.android.support:support-annotations:27.1.1@jar" level="project" />
to
<orderEntry type="library" scope="TEST" name="com.android.support:support-annotations:26.1.0@jar" level="project" />
its requires just few steps... 1. Go to module.app file. 2. Change your target sdk version and compile sdk version to latest version ( here it is 27) 3.then change appcompact version to 27.1.1 4. Sync gradle file
转到build.gradle(Module:app)文件,将compile 'com.android.support:support-annotations:27.1.1'
添加到依赖项中,然后再次单击“立即同步”。
Use
implementation 'com.android.support:appcompat-v7:27.1.1'
instead of
implementation 'com.android.support:appcompat-v7:26.1.1'
and change compileSdkVersion 26 to 27
Your root gradle file should contains:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
google ()
}
}
And the module gradle file should contains libraries like:
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "your.package.name"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' } // necessary for Android API 26
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-ads:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
}
It is just a example of typical simple gradle configuration. Use as needed
Track here latest versions https://mvnrepository.com/artifact/com.android.support
As of 28-9-2018 latest version is 28.0.0
.
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.