找不到满足版本限制的'androidx.annotation:annotation'版本:运行androidTests时出错

时间:2019-06-27 05:04:50

标签: android androidx

我最近已迁移到 androidX ,并将我的targetSdkVersion更新为29。此后,在尝试运行androidTests时收到错误消息:

Cannot find a version of 'androidx.annotation:annotation' that satisfies the version constraints: 
   Dependency path 'lullabies-v3:mobile:unspecified' --> 'androidx.annotation:annotation:1.1.0'
   Dependency path 'lullabies-v3:mobile:unspecified' --> 'com.android.support:support-annotations:28.0.0' because of the following reason: ENABLE_JETIFIER is enabled
   Constraint path 'lullabies-v3:mobile:unspecified' --> 'androidx.annotation:annotation:{strictly 1.0.0}' because of the following reason: debugRuntimeClasspath uses version 1.0.0
   Dependency path 'lullabies-v3:mobile:unspecified' --> 'com.android.support:support-annotations:28.0.0' because of the following reason: ENABLE_JETIFIER is enabled

我该如何解决?

1 个答案:

答案 0 :(得分:0)

最后,我解决了我的问题。我添加了

android {
    ...

    // Gradle automatically adds 'android.test.runner' as a dependency.
    useLibrary 'android.test.runner'

    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'
}

到我的模块级别build.gradle。

可选:您可能还需要添加以修复测试的编译错误:

id_rsa.pub

此处更多信息https://developer.android.com/training/testing/set-up-project