找不到满足版本约束的 'androidx.annotation:annotation' 版本: 运行 androidTests 时出错
Cannot find a version of 'androidx.annotation:annotation' that satisfies the version constraints: Error when run androidTests
我最近迁移到 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
我该如何解决?
终于解决了我的问题。我添加了
implementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
到我的模块级别 build.gradle。
可选:您可能还需要添加以修复测试的编译错误:
android {
...
// Gradle automatically adds 'android.test.runner' as a dependency.
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
这里有更多信息https://developer.android.com/training/testing/set-up-project
我在尝试构建我的应用程序时遇到了同样的问题,将其添加到我的 build.gradle 解决了它。
dependencies {
...
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.versionedparcelable:versionedparcelable:1.0.0'
androidTestImplementation 'androidx.versionedparcelable:versionedparcelable:1.0.0'
implementation 'androidx.core:core:1.0.1'
androidTestImplementation 'androidx.core:core:1.0.1'
.... }
我最近迁移到 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
我该如何解决?
终于解决了我的问题。我添加了
implementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
到我的模块级别 build.gradle。
可选:您可能还需要添加以修复测试的编译错误:
android {
...
// Gradle automatically adds 'android.test.runner' as a dependency.
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
这里有更多信息https://developer.android.com/training/testing/set-up-project
我在尝试构建我的应用程序时遇到了同样的问题,将其添加到我的 build.gradle 解决了它。
dependencies {
...
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.versionedparcelable:versionedparcelable:1.0.0'
androidTestImplementation 'androidx.versionedparcelable:versionedparcelable:1.0.0'
implementation 'androidx.core:core:1.0.1'
androidTestImplementation 'androidx.core:core:1.0.1'
.... }