找不到满足版本限制的'androidx.arch.core:core-common'版本

时间:2019-03-25 11:18:18

标签: android android-gradle androidx

如果添加以下行,则创建新的Android Studio项目(“空活动”类型):

    // 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"

对于应用程序的build.gradle文件,当您尝试为项目运行connectedCheck任务时,会看到错误。查看输出:

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

如果我使用相同的lifecycleVersioncoreTestingVersion值(例如2.0.0),则不会发生错误,但是lint抱怨核心测试依赖项具有更新的版本(2.0.1) 。 (尽管它至少运行了,但:P)我认为androidx的优点之一是它可以无问题地更新单个片段?

以下是显示问题的示例应用:https://github.com/ZOlbrys/CoreTestingVersionExample

在此项目中仅通过终端运行connectedCheck即可查看构建失败。

关于如何解决此问题的任何想法?

编辑:为此创建了google问题,请参见https://issuetracker.google.com/issues/129316035

2 个答案:

答案 0 :(得分:0)

要解决此问题,您将必须使用依赖项解决策略。这是我遇到类似问题时的解决方法: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表示为实现“ group name version

答案 1 :(得分:0)

我必须采取两种解决方法来解决此问题:

  1. 使用最新的Google Play服务库:https://developers.google.com/android/guides/google-services-plugin

  2. 如其他答案中所述:

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