Gradle 在 Android 中集成 Google 日历 API 和一个信号时出错

Gradle error when integrating Google Calendar API and One Signal in Android

我正在做一个 Android 项目,我正在将 Google Calendar API 和 One Signal 集成到同一个项目中。该项目已经有了用于通知的 OneSignal。现在我正在按照 google 指南整合 Google 日历 API,Here 。我卡在步骤 4:a。我添加了 gradle 依赖项进入我的 gradle 文件,但现在我收到错误

Warning: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.

Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
> Dependency Error. See console for details.

这是我当前的 gradle 文件

应用插件:'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
    defaultConfig {
        applicationId "com.example.user.icpdonline"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders=[onesignal_app_id: "b9389676-61e9-4622-a6f2-5b72e089c2ff",
        onesignal_google_project_number:"icpd-online-one-signal"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    testCompile 'junit:junit:4.12'

    compile 'com.onesignal:OneSignal:3.+@aar'
    compile 'com.google.android.gms:play-services-gcm:+'
    compile "com.google.android.gms:play-services-location:+"

    compile 'com.google.android.gms:play-services-auth:10.0.1'
//    compile 'com.google.android.gms:play-services-auth:10.2.0'
    compile 'pub.devrel:easypermissions:0.2.1'
    compile( 'com.google.api-client:google-api-client-android:1.22.0'){
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-calendar:v3-rev234-1.22.0'){
        exclude group: 'org.apache.httpcomponents'
    }
}

错误在线

compile 'com.google.android.gms:play-services-gcm:+'

当我将鼠标悬停在它上面时,它显示错误

    All com.google.android.gms libraries must use the exact same version 
specification(mixing versions can lead to runtime crashes). Found versions 
10.2.0,10.0.1.

我明白错误的含义,但我不知道如何解决。我尝试将版本添加到 gcm 行的末尾,但无济于事。我似乎也无法在任何地方找到答案。请帮我解决这个问题。

您的所有 Google Play 服务库 'com.google.android.gms:play-services-xxx' 应该使用相同的版本。

改变这个

compile 'com.google.android.gms:play-services-gcm:+'
compile "com.google.android.gms:play-services-location:+"

对此

compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
This answer by @drew solved the problem.

在您的应用中 build.gradle 添加 android { configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' } }。然而,最初的问题得到了回答。为了让以后的新手清楚这一点,请创建一个带有新错误

的新 post,而不是编辑带有不同错误的原始 post