带有Onesignal错误的Google Play服务

时间:2017-04-10 17:04:01

标签: android firebase gradle onesignal

所以我在我的项目中添加了Firebase,然后尝试在我的项目中添加Onesignal。但是我收到了这个错误。

  

请通过更新google-services插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或将com.google.android.gms的版本更新为10.2.1来修复版本冲突

我的应用级Gradle文件: -

  apply plugin: 'com.android.application'
  android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
    applicationId "com.kanishq.onesignal"
    minSdkVersion 14
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    manifestPlaceholders = [onesignal_app_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                            // Project number pulled from dashboard, local value is ignored.
                            onesignal_google_project_number: "xxxxxxxxx"]
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.onesignal:OneSignal:3.+@aar'

// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:+'

// Required for geotagging
compile "com.google.android.gms:play-services-location:+"

}
apply plugin: 'com.google.gms.google-services' } 

项目级别Build.gradle: -

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

我关注了Onesignal Documentation- here和Firebase文档

救救我!!要获得Onesignal和Firebase,并删除此错误。 感谢

2 个答案:

答案 0 :(得分:1)

您发布的依赖关系的相关性报告显示OneSignal:3.+正在解析为OneSignal:3.4.3,它对Firebase和Play服务库的版本10.0.1具有传递依赖性。更新您的依赖项,如下所示:

compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.onesignal:OneSignal:3.4.3@aar'

// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:10.0.1'

// Required for geotagging
compile 'com.google.android.gms:play-services-location:10.0.1'

尽管OneSignal文档使用“+”来获取最新版本,但是为了更好地查看和控制所使用的版本,指定依赖项的确切版本被认为更安全。

答案 1 :(得分:0)

在android studio中转到.. 工具> Android>使用gradle同步项目应解决此问题。如果没有手动添加

的版本

com.onesignal:OneSignal:3 + @ AAR

com.google.android.gms:播放服务-GCM:+

编译“com.google.android.gms:play-services-location:+”

最后syc the gradle