升级到最新的AndroidX库和Android Gradle插件后,当我在项目上运行lint时,lint构建将失败。
这一切都始于最新的Android Gradle插件,抱怨在创建项目时已经存在程序类型:com.google.common.util.concurrent.ListenableFuture
以下是错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestRuntimeClasspath'.
> Could not resolve com.google.guava:guava:23.6-android.
Required by:
project :app
> Cannot find a version of 'com.google.guava:guava' that satisfies the version constraints:
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'androidx.test.ext:truth:1.1.0' --> 'com.google.guava:guava:26.0-android'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.truth:truth:0.42' --> 'com.google.guava:guava:25.1-android'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'androidx.room:room-guava:2.1.0-alpha03' --> 'com.google.guava:guava:23.6-android'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.api-client:google-api-client:1.25.0' --> 'com.google.guava:guava:20.0'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'androidx.test.ext:truth:1.1.0' --> 'com.google.truth:truth:0.42' --> 'com.google.guava:guava:25.1-android'
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.guava:guava' strictly '23.6-android' because of the following reason: debugRuntimeClasspath uses version 23.6-android
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.guava:guava' strictly '23.6-android' because of the following reason: debugRuntimeClasspath uses version 23.6-android
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.guava:guava' strictly '23.6-android' because of the following reason: debugRuntimeClasspath uses version 23.6-android
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.guava:guava' strictly '23.6-android' because of the following reason: debugRuntimeClasspath uses version 23.6-android
> Could not resolve org.checkerframework:checker-compat-qual:2.0.0.
Required by:
project :app
> Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints:
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'com.google.truth:truth:0.42' --> 'org.checkerframework:checker-compat-qual:2.5.3'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'androidx.test.ext:truth:1.1.0' --> 'com.google.guava:guava:26.0-android' --> 'org.checkerframework:checker-compat-qual:2.5.2'
Dependency path 'C3 Mobile Code Base:app:unspecified' --> 'androidx.test.ext:truth:1.1.0' --> 'com.google.truth:truth:0.42' --> 'org.checkerframework:checker-compat-qual:2.5.3'
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'org.checkerframework:checker-compat-qual' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'org.checkerframework:checker-compat-qual' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'org.checkerframework:checker-compat-qual' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
Constraint path 'C3 Mobile Code Base:app:unspecified' --> 'org.checkerframework:checker-compat-qual' strictly '2.0.0' because of the following reason: debugRuntimeClasspath uses version 2.0.0
> Could not resolve com.google.errorprone:error_prone_annotations:2.1.3.
Required by:
project :app
我尝试放置以下内容,但不起作用:
subprojects {
project.configurations.all {
exclude group: 'com.google.guava', module: 'failureaccess'
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
if('guava' == details.requested.name) {
details.useVersion '27.0-android'
}
}
}
}
我能否知道错误的含义以及如何解决? 谢谢。
答案 0 :(得分:2)
我还试图解决这个问题,对我来说,这是由于新的Google地方信息库所致:
img=img.unsqueeze(dim=0)
这导致img=img.view(1, -1)
下的测试失败。
作为一种解决方法,我将此添加到了img = images[1]
img = img.unsqueeze(dim=0)
img=img.view(1, -1)
# TODO: Calculate the class probabilities (softmax) for img
ps = torch.exp(model(img))
:
img = images[1]
img=img.view(1, -1)
修复了lint和Android测试。不过还不确定后果。
编辑:在您的情况下,您可能需要放置implementation "com.google.android.libraries.places:places:1.0.0"
而不是androidTest
答案 1 :(得分:0)
更改
details.useVersion '27.0-android'
到
details.useVersion '23.6-android'
由于错误消息Could not resolve com.google.guava:guava:23.6-android.
告知它需要版本23.6-android
答案 2 :(得分:0)
检查您是否没有重复的变量依赖性。例如:
{color}
答案 3 :(得分:0)
将其放在应用模块的Build.gradle中
lintOptions {
checkReleaseBuilds false
abortOnError false
}