Resolved versions for app (26.1.0) and test app (2

2020-05-31 05:17发布

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!

10条回答
Explosion°爆炸
2楼-- · 2020-05-31 05:20

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.

查看更多
Deceive 欺骗
3楼-- · 2020-05-31 05:21

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

查看更多
ら.Afraid
4楼-- · 2020-05-31 05:22

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'
查看更多
Root(大扎)
5楼-- · 2020-05-31 05:27

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

查看更多
一纸荒年 Trace。
6楼-- · 2020-05-31 05:30

Recently I was getting this error again....I just go to build->rebuild project and it works everytime for me.

查看更多
Viruses.
7楼-- · 2020-05-31 05:40

Go to build.gradle(Module:app) file, add compile 'com.android.support:support-annotations:27.1.1' into dependencies, then click 'sync now' again.

查看更多
登录 后发表回答