web-dev-qa-db-ja.com

バージョンの制約を満たす「androidx.Arch.core:core-common」のバージョンが見つかりません

次の行を追加すると、新しい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の利点の1つは、問題なく個々の部分を更新できることだと思いましたか?

これが問題を示すサンプルアプリです: https://github.com/ZOlbrys/CoreTestingVersionExample

このプロジェクトでターミナルを介してconnectedCheckを実行するだけで、ビルドの失敗を確認できます。

これを修正する方法に関するアイデアはありますか?

編集:このためにGoogleの問題を作成しました https://issuetracker.google.com/issues/129316035 を参照してください

15
Zach

この問題を解決するには、依存関係解決戦略を使用する必要があります。これは、同様の問題が発生したときに解決した方法です 「androidx.Arch」、「androidx.room」などのバージョンが見つかりません

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"として表されます

9
George

この問題を解決するには、2つの回避策を実行する必要がありました。

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