Onesignal-android-sdk: Build Failed because of version conflicts

Created on 24 Nov 2019  路  2Comments  路  Source: OneSignal/OneSignal-Android-SDK

Description:
Hi, I am using latest version of oneSignal SDK, currently I am having hard time compiling my project and its driving me crazy.
I've a module name called onesignal where I've in build.gradle have onesignal and in my app module I inject it.

Environment

  1. OneSignal SDK Version: 3.12.3, classpath: 0.12.2
  2. How did you add the SDK to your project: Gradle.

Steps to Reproduce Issue:
Example:

  1. Create a modular android app, where there are 3 modules
    . app (main module)
    . firebase (for remote config and abtesting stuff)
    . oneSignal (for one signal configs)
  • Error:
Starting dependency analysis
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.onesignal, artifactId=OneSignal, version=3.12.3), toArtifact=Artifact(groupId=com.google.android.gms, artifactId=play-services-location), toArtifactVersionString=[10.2.1, 16.0.99])
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.android.gms, artifactId=play-services-location)
NOTE: com.google.android.gms translated to c.g.a.g for brevity. Same for com.google.firebase -> c.g.f
-- :app-debugCompileClasspath-onesignal:0.0.0 task/module dep -> com.onesignal:[email protected]
---- com.onesignal:OneSignal:3.12.3 library depends -> c.g.a.g:play-services-location@[10.2.1, 16.0.99]
-- :app-debugCompileClasspath-onesignal:0.0.0 task/module dep -> com.onesignal:OneSignal@{strictly 3.12.3}
---- com.onesignal:OneSignal:3.12.3 library depends -> c.g.a.g:play-services-location@[10.2.1, 16.0.99]
-- :app-debugCompileClasspath-onesignal:0.0.0 task/module dep -> c.g.a.g:play-services-location@{strictly 15.0.1}

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':onesignal:compileDebugRenderscript'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
  1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.onesignal:OneSignal:3.12.3 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 15.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends on project 'onesignal' which depends onto com.onesignal:[email protected]
  -- Project 'app' depends on project 'onesignal' which depends onto com.onesignal:OneSignal@{strictly 3.12.3}
  -- Project 'app' depends on project 'onesignal' which depends onto com.google.android.gms:play-services-location@{strict
  ly 15.0.1}
  • onesignal/build.gradle
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.2'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com'}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion Versions.compileSdk

    defaultConfig {
        minSdkVersion Versions.minSdk
        targetSdkVersion Versions.targetSdk
        versionCode Versions.versionCode
        versionName Versions.versionName

        testInstrumentationRunner Dependencies.android_junit_runner
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
        }
        sit {
            debuggable true
            minifyEnabled false
        }
        uat {
            debuggable true
            minifyEnabled true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

apply from: '../dependencies/dagger.gradle'
apply from: '../dependencies/kotlin.gradle'

dependencies {

    implementation project(Modules.di)
    implementation 'com.onesignal:OneSignal:3.12.3'

    implementation Dependencies.support_appcompat
    testImplementation Dependencies.test_junit
    androidTestImplementation Dependencies.test_androidx_runner
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
  • firebase/build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion Versions.compileSdk

    defaultConfig {
        minSdkVersion Versions.minSdk
        targetSdkVersion Versions.targetSdk
        versionCode Versions.versionCode
        versionName Versions.versionName
        testInstrumentationRunner Dependencies.android_junit_runner
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

apply from: '../dependencies/dagger.gradle'
apply from: '../dependencies/kotlin.gradle'

dependencies {
    implementation project(Modules.di)

    implementation "com.google.firebase:firebase-core:17.0.1"
    implementation Dependencies.support_appcompat
}
  • app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {

    compileSdkVersion Versions.compileSdk
    defaultConfig {
        applicationId "my.example.onesignal"
        minSdkVersion Versions.minSdk
        targetSdkVersion Versions.targetSdk
        versionCode Versions.versionCode
        versionName Versions.versionName
        testInstrumentationRunner Dependencies.android_junit_runner
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

        manifestPlaceholders = [onesignal_app_id: 'xxx-xxx-xxx-xxx',
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: 'REMOTE']

    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"

            testCoverageEnabled true
            debuggable true
            minifyEnabled false
        }
        sit {
            applicationIdSuffix ".sit"

            debuggable true
            minifyEnabled false
        }
        uat {
            applicationIdSuffix ".uat"

            debuggable true
            minifyEnabled true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    dexOptions {
        javaMaxHeapSize '4096m'
    }

}

apply from: 'tasks.gradle'
apply from: '../dependencies/dagger.gradle'

dependencies {
    api project(Modules.core)
    api project(Modules.account)

    implementation project(Modules.onesignal)
    implementation project(Modules.firebase)

    implementation Dependencies.support_design
}

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

Can anyone please help me with that? I tried adding "googleServices { disableVersionCheck = false }"

Most helpful comment

I ran into this issue on the react native side. I was able to fix it by downgrading the google-services dependency from 4.2.0 to 4.1.0.

All 2 comments

Issue resolved after using the latest gradle plugin, latest release and adding this line implementation 'com.google.firebase:firebase-messaging:18.0.0' in my onesignal module.

I ran into this issue on the react native side. I was able to fix it by downgrading the google-services dependency from 4.2.0 to 4.1.0.

Was this page helpful?
0 / 5 - 0 ratings