且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:与依赖项“com.google.code.findbugs:jsr305"冲突

更新时间:2023-01-14 07:39:34

在您的应用程序的 build.gradle 中添加以下内容:

android {配置.所有{resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'}}

强制 Gradle 只编译您为所有依赖项声明的版本号,无论依赖项声明的是哪个版本号.

I created a new project in Android Studio 2.2 Preview 1 with Android App and Backend module with Google Messaging. This is the app file:

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')
}

But it's giving:

Error:Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (1.3.9) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

I am new to Android and not able to find what is this error. How do I fix it?

In your app's build.gradle add the following:

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

Enforces Gradle to only compile the version number you state for all dependencies, no matter which version number the dependencies have stated.