错误:与依赖项'com.google.code.findbugs:jsr305'冲突。

246

我在 Android Studio 2.2 Preview 1 中创建了一个新项目,包含 Android 应用程序和后端模块,并使用了 Google Messaging。这是应用程序文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support:support-annotations:23.4.0'
    compile project(path: ':backend', configuration: 'android-endpoints')
}

但是它显示:

错误:与依赖项 'com.google.code.findbugs: jsr305' 冲突。 应用程序(1.3.9)和测试应用程序(2.0.1)的已解析版本不同。请参见http://g.co/androidstudio/app-test-app-conflict以获取详细信息。

我是Android开发新手,不知道这个错误是什么。我该如何解决?

15个回答

1

如果在Android 3.0.1中遇到相同的错误,只需更新compileSdkVersiontargetSdkVersion版本至27,并在dependencies中实现com.android.support:appcompat-v7:27.1.1即可解决。


1
我尝试使用Airbnb Deeplink Dispatch,但出现了错误。我还需要从AnnotationProcessor中排除FindBugs组。
//airBnb
    compile ('com.airbnb:deeplinkdispatch:3.1.1'){
        exclude group:'com.google.code.findbugs'
    }
    annotationProcessor ('com.airbnb:deeplinkdispatch-processor:3.1.1'){
        exclude group:'com.google.code.findbugs'
    }

1
在项目“:app”中,您可以将以下内容添加到您的app/build.gradle文件中:
android {
 configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
 }
 }

1
对于react-native-firebase,将以下内容添加到app/build.gradle的依赖项部分,使其对我有效:
implementation('com.squareup.okhttp3:okhttp:3.12.1') { force = true }
implementation('com.squareup.okio:okio:1.15.0') { force = true }
implementation('com.google.code.findbugs:jsr305:3.0.2') { force = true}

这是我第一次看到 { force = true } 标志。我尝试了一下,它立即为我工作了。我的项目需要保持 androidx.appcompat 在 v1.0.2 版本,因为我添加的一个库将其依赖设置为 v1.1.0。 - MikeOscarEcho

0

REACT NATIVE

如果你正在寻找React Native的解决方案,那么请在受影响的node_modules gradle构建文件中编写此片段,例如我的情况下是Firebase。

android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接