Kanishq Gupta
Kanishq Gupta

Reputation: 151

Google Play Service with Onesignal error

So I added Firebase in my project and then tried to add Onesignal in my project. But I getting this error.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.1.

My App Level Gradle File :-

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

Project Level 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
}

I followed Onesignal Documentation- here and Firebase Docs

Help me!! To get Onesignal and Firebase both, and remove this error. Thanks

Upvotes: 1

Views: 7248

Answers (2)

Bob Snyder
Bob Snyder

Reputation: 38289

A dependency report for the dependencies you posted shows that OneSignal:3.+ is resolving to OneSignal:3.4.3, which has transitive dependencies on version 10.0.1 of the Firebase and Play Services libraries. Update your dependencies as shown below:

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'

Although OneSignal docs use '+' to get the latest version, it's considered safer to specify the exact version of dependencies to get better visibility and control of the versions used.

Upvotes: 2

KUSHA B K
KUSHA B K

Reputation: 1489

In android studio go to .. Tool > Android > Sync Project with gradle should fix this issue.if not manually add the version for

com.onesignal:OneSignal:3.+@aar

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

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

finally syc the gradle

Upvotes: 0

Related Questions