android-studio - 错误:Conflict with dependency 'com.google.code.findbugs:jsr305'

标签 android-studio gradle google-cloud-messaging android-gradle-plugin build.gradle

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

但它正在给予:

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.

我是 Android 新手,无法找到此错误是什么。我该如何修复它?

最佳答案

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

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.

关于android-studio - 错误:Conflict with dependency 'com.google.code.findbugs:jsr305' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37347326/

相关文章:

java.lang.ClassNotFoundException : Cannot find implementation for 异常

java - Gradle + IntelliJ : HotSwap in a plain Java application

android - GCM 无法在实时服务器上运行

切换到 gradle 后,android 自定义 View 属性不起作用

ios - 在 iOS 上使用 GCM 获取 'unknown token'

Android 设备未从 Amazon SNS 接收 GCM 通知

android-studio - Android Studio 2.3.1;依赖项和同步项目

android - Could not call incremental task 错误在Android Studio中

android - java.lang.NoClassDefFoundError : org. apache.commons.net.ftp.FTPClient

java - 当 EditText 为空时 Android 应用程序崩溃