无法找到满足版本约束的'com.google.code.findbugs:jsr305'的版本。[英] Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints

本文是小编为大家收集整理的关于无法找到满足版本约束的'com.google.code.findbugs:jsr305'的版本。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

当生成签名的APK用于REALSE时,我会收到此错误消息:

Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints: 
   Dependency path 'XX:app:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.2-alpha01' --> 'com.google.code.findbugs:jsr305:2.0.1'
   Constraint path 'XX:app:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '1.3.9' because of the following reason: debugRuntimeClasspath uses version 1.3.9

这是我的应用:gradle

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.XX.XX"
    minSdkVersion 25
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}


 }

 dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.guava:guava:22.0-android'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
}

但是,如果我为调试而构建它可以正常工作,但是当我生成签名版本时,我收到了此消息,我尝试使用Google,但似乎没有找到正确的答案.

推荐答案

我今天也有类似的问题,发现了这一点: https://github.com/trello/rxlifecycle/154

通过编辑依赖项下的(模块:应用)中的gradle build.gradle来修改我的问题:

androidTestImplementation 'com.google.code.findbugs:jsr305:1.3.9'

我最初尝试了一个不同的版本编号,但有一个错误告诉我要使用的版本,因此您可能需要进行几次尝试.

其他推荐答案

我不确定此问题的确切原因.但是,在尝试了多个选项之后,它会自动开始工作

如果您使用的是房间组件,并为其编写测试.您需要添加以下依赖项.

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:2.1.0"

// Test helpers
testImplementation "androidx.room:room-testing:2.1.0"

其他推荐答案

对于那些想知道如何解决依赖关系冲突问题的人.

我的依赖性:

// Conflicted transitive dependency for androidx.test:monitor
- org.robolectric:robolectric -> androidx.test:monitor:1.2.0 (forced to use 1.1.0)
- androidx.test:core -> androidx.test:monitor:1.1.0
- androidx.test:runner -> androidx.test:monitor:1.1.0

// Conflicted transitive dependency for com.google.guava:listenablefuture
- androidx.test.ext:truth -> androidx.test:monitor:9999.0 (forced to use 1.0)
- androidx.work:work-runtime -> androidx.test:monitor:1.0

决议1

我最终检查了Required by&Could not resolve [dependency] 关键字 to 确定 和 选择 我想要哪个版本 include ,例如:androidx.test:monitor:1.1.0&com.google.guava:listenablefuture:1.0,然后 dubl 通过做这样的事情,其余的事情:

    androidTestImplementation(org.robolectric:robolectric:4.3.1) {
        exclude(group = "androidx.test", module = "monitor")
        exclude(group = "com.google.guava", module = "listenablefuture")
    }

我正在从org.robolectric:robolectric:4.3.1中强迫androidx.test:module,并使用androidx.test:module:1.1.0 androidx.test:core&androix.test:runner所要求的androidx.test:module:1.1.0.

对于guavalistener我也不使用真理,所以我删除了它,但是如果您确实需要它,则可以这样做以排除/选择 必需的依赖关系 您要包括

决议2

如果您使用Roboelectric,则可能想排除一些依赖项,以及 @finder2 .

上面的方法是一个hotfix,您也可能需要仔细选择要使用的传递依赖性或仅删除不需要的依赖项(truth是我的示例)

以下是修复findbugs依赖关系冲突后的错误构建输出,并且使用上述方法,我可以修复它.

* What went wrong:
Could not determine the dependencies of task ':app:preDevDebugAndroidTestBuild'.
> Could not resolve all task dependencies for configuration ':app:devDebugAndroidTestRuntimeClasspath'.
   > Could not resolve androidx.test:monitor:{strictly 1.1.0}.
     Required by:
         project :app
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve androidx.test:monitor:1.2.0.
     Required by:
         project :app > org.robolectric:robolectric:4.3.1
         project :app > org.robolectric:robolectric:4.3.1 > org.robolectric:shadows-framework:4.3.1
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve androidx.test:monitor:1.1.0.
     Required by:
         project :app > androidx.test:core:1.0.0
         project :app > androidx.test:runner:1.1.0
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve com.google.guava:listenablefuture:1.0.
     Required by:
         project :app > androidx.work:work-runtime:2.2.0
      > Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.work:work-runtime:2.2.0' --> 'com.google.guava:listenablefuture:1.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test.ext:truth:1.0.0' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

   > Could not resolve com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava.
     Required by:
         project :app > androidx.test.ext:truth:1.0.0 > com.google.guava:guava:27.0.1-jre
      > Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.work:work-runtime:2.2.0' --> 'com.google.guava:listenablefuture:1.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test.ext:truth:1.0.0' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

本文地址:https://www.itbaoku.cn/post/1937928.html

问题描述

When generated signed APK for realse i get this error message:

Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints: 
   Dependency path 'XX:app:unspecified' --> 'androidx.test.espresso:espresso-core:3.1.2-alpha01' --> 'com.google.code.findbugs:jsr305:2.0.1'
   Constraint path 'XX:app:unspecified' --> 'com.google.code.findbugs:jsr305' strictly '1.3.9' because of the following reason: debugRuntimeClasspath uses version 1.3.9

This is my app:gradle

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.XX.XX"
    minSdkVersion 25
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}


 }

 dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.guava:guava:22.0-android'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
}

However if i build for debug it works fine, but when i generate signed release I get this message, ive tried to google but didnt seem to find the right answer.

推荐答案

I had a similar problem today and found this : https://github.com/trello/RxLifecycle/issues/154

Manged to fix my problem by editing the Gradle Scripts build.gradle in the (module:app) under dependancies adding :

androidTestImplementation 'com.google.code.findbugs:jsr305:1.3.9'

I originally tried a different version number but got an error that told me what version to use, so you may need to have a couple of tries.

其他推荐答案

I am not sure of exact cause of this problem. However, after trying several options, it automatically started working

If you are using Room component, and writing tests for it. You need to add the following dependencies.

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:2.1.0"

// Test helpers
testImplementation "androidx.room:room-testing:2.1.0"

其他推荐答案

For those wondering how to solve the dependencies conflict issues.

My dependencies:

// Conflicted transitive dependency for androidx.test:monitor
- org.robolectric:robolectric -> androidx.test:monitor:1.2.0 (forced to use 1.1.0)
- androidx.test:core -> androidx.test:monitor:1.1.0
- androidx.test:runner -> androidx.test:monitor:1.1.0

// Conflicted transitive dependency for com.google.guava:listenablefuture
- androidx.test.ext:truth -> androidx.test:monitor:9999.0 (forced to use 1.0)
- androidx.work:work-runtime -> androidx.test:monitor:1.0

Resolutions 1

I ended-up checking for the Required by & Could not resolve [dependency] keyword to determine and choose which version I want to include, e.g: androidx.test:monitor:1.1.0 & com.google.guava:listenablefuture:1.0 and then exclude for the rest by doing something like this:

    androidTestImplementation(org.robolectric:robolectric:4.3.1) {
        exclude(group = "androidx.test", module = "monitor")
        exclude(group = "com.google.guava", module = "listenablefuture")
    }

I'm forcing the exclude androidx.test:module from org.robolectric:robolectric:4.3.1 and to use the androidx.test:module:1.1.0 that required by both androidx.test:core & androix.test:runner.

Also the same for guavalistener I'm not using truth, so I remove it, but if you do need it, you can do the same to exclude/choose the required dependency that you want to include

Resolutions 2

If you using roboelectric, you might wanna to exclude a few dependencies as well like here from @finder2 java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class org.apache.maven.artifact.Artifact found in modules maven-ant-tasks-2.1.3.jar

The above method was a hotfix, also you might want to choose carefully which transitive dependency that you want to use or just remove the dependency that you don't needed (truth is for my example)

Below is the error build output after fixing the findbugs dependencies conflict, and with the above method, I'm able to fix it.

* What went wrong:
Could not determine the dependencies of task ':app:preDevDebugAndroidTestBuild'.
> Could not resolve all task dependencies for configuration ':app:devDebugAndroidTestRuntimeClasspath'.
   > Could not resolve androidx.test:monitor:{strictly 1.1.0}.
     Required by:
         project :app
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve androidx.test:monitor:1.2.0.
     Required by:
         project :app > org.robolectric:robolectric:4.3.1
         project :app > org.robolectric:robolectric:4.3.1 > org.robolectric:shadows-framework:4.3.1
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve androidx.test:monitor:1.1.0.
     Required by:
         project :app > androidx.test:core:1.0.0
         project :app > androidx.test:runner:1.1.0
      > Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'androidx.test:monitor:1.2.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'androidx.test:monitor:{strictly 1.1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:core:1.0.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test:runner:1.1.0' --> 'androidx.test:monitor:1.1.0'
           Dependency path 'android-etalase-app:app:unspecified' --> 'org.robolectric:robolectric:4.3.1' --> 'org.robolectric:shadows-framework:4.3.1' --> 'androidx.test:monitor:1.2.0'

   > Could not resolve com.google.guava:listenablefuture:1.0.
     Required by:
         project :app > androidx.work:work-runtime:2.2.0
      > Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.work:work-runtime:2.2.0' --> 'com.google.guava:listenablefuture:1.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test.ext:truth:1.0.0' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

   > Could not resolve com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava.
     Required by:
         project :app > androidx.test.ext:truth:1.0.0 > com.google.guava:guava:27.0.1-jre
      > Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints: 
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.work:work-runtime:2.2.0' --> 'com.google.guava:listenablefuture:1.0'
           Constraint path 'android-etalase-app:app:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: devDebugRuntimeClasspath uses version 1.0
           Dependency path 'android-etalase-app:app:unspecified' --> 'androidx.test.ext:truth:1.0.0' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'