Android 找不到';core:core common';满足版本约束的
创建新的Android Studio项目(空活动类型)后,如果添加以下行:Android 找不到';core:core common';满足版本约束的,android,android-gradle-plugin,androidx,Android,Android Gradle Plugin,Androidx,创建新的Android Studio项目(空活动类型)后,如果添加以下行: // Lifecycle/View Models def lifecycleVersion = '2.0.0' implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion" annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifec
// 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
如果我使用相同的lifecycleVersion
和coreTestingVersion
值(例如2.0.0),则不会发生错误,但lint抱怨核心测试依赖项有一个更新版本(2.0.1)。(不过,至少它可以运行:P)我认为,androidx
的一个优点是它可以允许更新单个片段而不会出现问题
以下是显示问题的示例应用程序:
只需通过此项目中的终端运行connectedCheck
,即可看到构建失败
有没有办法解决这个问题
编辑:为此创建了google问题,请参见要解决此问题,您必须使用依赖项解决策略。当我面临类似问题时,我就是这样解决的:
每个依赖项的Fyi表示为实现“组*:名称:*version”我必须采取两种变通方法来解决此问题:
configurations.all
{
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.arch.core'
&& !details.requested.name.contains('core-runtime')) {
details.useVersion "2.0.1"
}
}
是否尝试使缓存无效并重新启动?是!我还完全重新启动了计算机,并在两台不同的计算机上进行了检查,但问题仍然存在。请尝试检查是否启用或禁用了脱机工作。在android studiooffline中,在我的设置中禁用了脱机工作。我为此创建了一个android问题:到目前为止,此问题似乎有效-我将进一步调查,如果我看不出这有什么问题,我也会在谷歌上发表文章。。。谢谢我还建议您在您的家属中使用Kotlin DSL。这对我的情况不起作用,您在哪里添加的?我们需要在gradle中放在哪里?您在哪里添加的?关于依赖关系?@MadonaSyombua是的。内部依赖项{}块。确保您也有最新的Google play服务库。来源问题:
configurations.all
{
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.arch.core'
&& !details.requested.name.contains('core-runtime')) {
details.useVersion "2.0.1"
}
}