Mariano L
Mariano L

Reputation: 1879

Getting "Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints" after Android Studio update

After updating to the last version I cannot build the APK anymore, and I can't understand the gradle error.

This is the module config:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.myapp.mymodule"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 31
        versionName "2.07"
        project.archivesBaseName = "app-name_v" + defaultConfig.versionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    implementation 'ch.acra:acra:4.9.2'

}

This is the error that is shown in the Build screen:

Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints: 
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'ch.acra:acra:4.9.2' --> 'com.android.support:support-annotations:24.1.1'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support.test:monitor:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support.test.espresso:espresso-core:3.0.2' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-vector-drawable:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:design:26.1.0' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:design:26.1.0' --> 'com.android.support:recyclerview-v7:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:design:26.1.0' --> 'com.android.support:transition:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-compat:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-media-compat:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-core-utils:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support:appcompat-v7:26.1.0' --> 'com.android.support:support-v4:26.1.0' --> 'com.android.support:support-core-ui:26.1.0' --> 'com.android.support:support-annotations:26.1.0'
   Constraint path 'my-project:my-module:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following reason: debugRuntimeClasspath uses version 26.1.0
   Constraint path 'my-project:my-module:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following reason: debugRuntimeClasspath uses version 26.1.0
   Constraint path 'my-project:my-module:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following reason: debugRuntimeClasspath uses version 26.1.0
   Constraint path 'my-project:my-module:unspecified' --> 'com.android.support:support-annotations' strictly '26.1.0' because of the following reason: debugRuntimeClasspath uses version 26.1.0

The app build completly without erros, and can run in the devices without any problem.

I've tried the suggestions in : Cannot find a version of 'com.android.support:support-annotations' that satisfies the version constraints but any of those worked for me.

This is the gradle.config:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Upvotes: 1

Views: 7468

Answers (1)

Mariano L
Mariano L

Reputation: 1879

I guess I didn't pay attention correctly. In the build log:

   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support.test:monitor:1.0.2' --> 'com.android.support:support-annotations:27.1.1'
   Dependency path 'my-project:my-module:unspecified' --> 'com.android.support.test.espresso:espresso-core:3.0.2' --> 'com.android.support.test:runner:1.0.2' --> 'com.android.support:support-annotations:27.1.1'

The testImplementation was using an upper version of that. I removed those dependencies and now the build is correct. I think I need to set a lower version of the testImplementation to put it back in the future.

Upvotes: 4

Related Questions