Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find a version of 'androidx.arch.core:core-common' that satisfies the version constraints

With a new Android Studio project created (Empty Activity type), if you add the following lines:

    // Lifecycle/View Models
    def lifecycleVersion = '2.0.0'
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
    annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycleVersion"

    // Core testing
    def coreTestingVersion = '2.0.1'
    testImplementation "androidx.arch.core:core-testing:$coreTestingVersion"
    androidTestImplementation "androidx.arch.core:core-testing:$coreTestingVersion"

To the app's build.gradle file you will see errors when you try to run the connectedCheck task for the project. See output:

Zachs-MBP:CoreTestingVersionExample Zach$ ./gradlew connectedCheck

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugAndroidTestBuild'.
> Could not resolve all task dependencies for configuration ':app:debugAndroidTestRuntimeClasspath'.
   > Could not resolve androidx.arch.core:core-common:2.0.0.
     Required by:
         project :app
      > Cannot find a version of 'androidx.arch.core:core-common' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1' --> 'androidx.arch.core:core-common:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-runtime:2.1.0-alpha03' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.appcompat:appcompat:1.1.0-alpha03' --> 'androidx.fragment:fragment:1.1.0-alpha05' --> 'androidx.activity:activity:1.0.0-alpha05' --> 'androidx.savedstate:savedstate:1.0.0-alpha02' --> 'androidx.arch.core:core-common:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0

   > Could not resolve androidx.arch.core:core-runtime:2.0.0.
     Required by:
         project :app
      > Cannot find a version of 'androidx.arch.core:core-runtime' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0

   > Could not resolve androidx.arch.core:core-runtime:2.0.1.
     Required by:
         project :app > androidx.arch.core:core-testing:2.0.1
      > Cannot find a version of 'androidx.arch.core:core-runtime' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0

   > Could not resolve androidx.arch.core:core-common:2.0.0.
     Required by:
         project :app > androidx.lifecycle:lifecycle-extensions:2.0.0
         project :app > androidx.lifecycle:lifecycle-livedata:2.0.0
         project :app > androidx.lifecycle:lifecycle-runtime:2.1.0-alpha03
         project :app > androidx.lifecycle:lifecycle-livedata-core:2.0.0
         project :app > androidx.savedstate:savedstate:1.0.0-alpha02
      > Cannot find a version of 'androidx.arch.core:core-common' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1' --> 'androidx.arch.core:core-common:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-runtime:2.1.0-alpha03' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.appcompat:appcompat:1.1.0-alpha03' --> 'androidx.fragment:fragment:1.1.0-alpha05' --> 'androidx.activity:activity:1.0.0-alpha05' --> 'androidx.savedstate:savedstate:1.0.0-alpha02' --> 'androidx.arch.core:core-common:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0

   > Could not resolve androidx.arch.core:core-runtime:2.0.0.
     Required by:
         project :app > androidx.lifecycle:lifecycle-extensions:2.0.0
         project :app > androidx.lifecycle:lifecycle-livedata:2.0.0
         project :app > androidx.lifecycle:lifecycle-livedata-core:2.0.0
      > Cannot find a version of 'androidx.arch.core:core-runtime' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-runtime:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-runtime' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0

   > Could not resolve androidx.arch.core:core-common:2.0.1.
     Required by:
         project :app > androidx.arch.core:core-runtime:2.0.1
      > Cannot find a version of 'androidx.arch.core:core-common' that satisfies the version constraints: 
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-testing:2.0.1' --> 'androidx.arch.core:core-runtime:2.0.1' --> 'androidx.arch.core:core-common:2.0.1'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-runtime:2.1.0-alpha03' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.lifecycle:lifecycle-extensions:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.arch.core:core-common:2.0.0'
           Dependency path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.appcompat:appcompat:1.1.0-alpha03' --> 'androidx.fragment:fragment:1.1.0-alpha05' --> 'androidx.activity:activity:1.0.0-alpha05' --> 'androidx.savedstate:savedstate:1.0.0-alpha02' --> 'androidx.arch.core:core-common:2.0.0'
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Constraint path 'CoreTestingVersionExample:app:unspecified' --> 'androidx.arch.core:core-common' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

If I use the same lifecycleVersion and coreTestingVersion value (2.0.0 for example) the errors do not occur, but lint complains that the core testing dependencies have an updated version (2.0.1). (At least it runs, though :P) I thought one of the advantages of androidx was that it would allow for updating individual pieces without issue?

Here's a sample app showing the issue: https://github.com/ZOlbrys/CoreTestingVersionExample

Simply run connectedCheck via terminal in this project to see the build fail.

Any ideas on how to fix this?

edit: created google issue for this, see https://issuetracker.google.com/issues/129316035

like image 890
Zach Avatar asked Mar 25 '19 11:03

Zach


1 Answers

To resolve this issue you will have to use a dependency resolution strategy. This is how I resolved it when I faced a similar issue: Cannot find version of 'androidx.arch', 'androidx.room', etc

configurations.all
            {
                resolutionStrategy.eachDependency { details ->
                    if (details.requested.group == 'androidx.arch.core'
                            && !details.requested.name.contains('core-runtime')) {
                        details.useVersion "2.0.1"
                    }

}

Fyi for each dependency is represented as implementation "group*:name:*version"

like image 56
George Avatar answered Oct 07 '22 16:10

George