简而言之
我无法使用以下添加的依赖项构建最小的新Android Studio项目:
dependencies {
...
implementation 'com.google.guava:guava:27.0.1-android'
androidTestImplementation "com.google.truth:truth:1.0"
}
如何重现
我就是这样做的,但当然还有其他方法。
- 在Android Studio 3.5.2中:
- 文件→新建→新建项目...
- 在创建新项目对话框中:
- 手机和平板电脑选项卡 →不添加活动→下一步
- 名称,包名,保存位置:随便你
- 语言:Java
- 最低 API 级别:API 28
- 该项目将支持即时应用程序:已禁用
- 结束
- 在./app/build.gradle:
- 添加
implementation 'com.google.guava:guava:27.0.1-android'
和androidTestImplementation "com.google.truth:truth:1.0"
到dependencies
- 添加
- 在ExampleInstrumentedTest.java 中
- 右键单击
class ExampleInstrumentedTest
并选择运行'ExampleInstrumentedTest'
- 右键单击
预期
测试通过
实际
构建错误:
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 org.checkerframework:checker-compat-qual:{strictly 2.5.2}.
Required by:
project :app
> Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'org.checkerframework:checker-compat-qual:2.5.5'
Constraint path 'sdfsf:app:unspecified' --> 'org.checkerframework:checker-compat-qual:{strictly 2.5.2}' because of the following reason: debugRuntimeClasspath uses version 2.5.2
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'org.checkerframework:checker-compat-qual:2.5.2'
> Could not resolve com.google.errorprone:error_prone_annotations:{strictly 2.2.0}.
Required by:
project :app
> Cannot find a version of 'com.google.errorprone:error_prone_annotations' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'com.google.errorprone:error_prone_annotations:2.3.1'
Constraint path 'sdfsf:app:unspecified' --> 'com.google.errorprone:error_prone_annotations:{strictly 2.2.0}' because of the following reason: debugRuntimeClasspath uses version 2.2.0
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'com.google.errorprone:error_prone_annotations:2.2.0'
> Could not resolve org.checkerframework:checker-compat-qual:2.5.5.
Required by:
project :app > com.google.truth:truth:1.0
> Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'org.checkerframework:checker-compat-qual:2.5.5'
Constraint path 'sdfsf:app:unspecified' --> 'org.checkerframework:checker-compat-qual:{strictly 2.5.2}' because of the following reason: debugRuntimeClasspath uses version 2.5.2
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'org.checkerframework:checker-compat-qual:2.5.2'
> Could not resolve com.google.errorprone:error_prone_annotations:2.3.1.
Required by:
project :app > com.google.truth:truth:1.0
> Cannot find a version of 'com.google.errorprone:error_prone_annotations' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'com.google.errorprone:error_prone_annotations:2.3.1'
Constraint path 'sdfsf:app:unspecified' --> 'com.google.errorprone:error_prone_annotations:{strictly 2.2.0}' because of the following reason: debugRuntimeClasspath uses version 2.2.0
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'com.google.errorprone:error_prone_annotations:2.2.0'
> Could not resolve org.checkerframework:checker-compat-qual:2.5.2.
Required by:
project :app > com.google.guava:guava:27.0.1-android
> Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'org.checkerframework:checker-compat-qual:2.5.5'
Constraint path 'sdfsf:app:unspecified' --> 'org.checkerframework:checker-compat-qual:{strictly 2.5.2}' because of the following reason: debugRuntimeClasspath uses version 2.5.2
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'org.checkerframework:checker-compat-qual:2.5.2'
> Could not resolve com.google.errorprone:error_prone_annotations:2.2.0.
Required by:
project :app > com.google.guava:guava:27.0.1-android
> Cannot find a version of 'com.google.errorprone:error_prone_annotations' that satisfies the version constraints:
Dependency path 'sdfsf:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'com.google.errorprone:error_prone_annotations:2.3.1'
Constraint path 'sdfsf:app:unspecified' --> 'com.google.errorprone:error_prone_annotations:{strictly 2.2.0}' because of the following reason: debugRuntimeClasspath uses version 2.2.0
Dependency path 'sdfsf:app:unspecified' --> 'com.google.guava:guava:27.0.1-android' --> 'com.google.errorprone:error_prone_annotations:2.2.0'
如何解决此构建问题?