Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play services dependency issue #1470

Closed
rigo-ptz opened this issue Oct 27, 2021 · 6 comments
Closed

Play services dependency issue #1470

rigo-ptz opened this issue Oct 27, 2021 · 6 comments

Comments

@rigo-ptz
Copy link

Description:

I tried to integrate the SDK by following the documentation https://documentation.onesignal.com/docs/android-sdk-setup#step-2-add-onesignal-gradle-plugin-and-sdk but Gradle sync fails. Could you check play-services-base version, please?

In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
0, 17.6.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.onesignal:OneSignal:4.6.1 -> com.google.android.gms:play-services-base@[17.0.0, 17.6.99], but pl
ay-services-base version was 17.6.0.

...

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the strict-version-matcher-plugin Gradle plugin, report issu
es at https://github.com/google/play-services-plugins and disable by removing the reference to the plugin ("apply 'stric
t-version-matcher-plugin'") from build.gradle.

Environment

  1. classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.4'
  2. 'com.onesignal:OneSignal:[4.0.0, 4.99.99]',

Steps to Reproduce Issue:

  1. Add the following dependencies
    "com.google.android.gms:play-services-base:17.6.0",
    "com.google.android.gms:play-services-maps:17.0.1",
    "com.google.android.gms:play-services-auth:19.2.0,
    "com.google.android.gms:play-services-wallet:18.1.3",
  2. Add OneSignal dependency.
  3. Sync Gradle
@jkasten2
Copy link
Member

jkasten2 commented Oct 28, 2021

@rigo-ptz Thanks for reporting. Could you share your root build.gradle and your app/build.gradle?

Some possible fixes you can try:

  1. If you are using com.google.gms:google-services:4.1.0 upgrading to 4.2.0 or newer.
  2. Double check step 2.2 in the OneSignal Android setup guide
    • Ensure you have id 'com.onesignal.androidsdk.onesignal-gradle-plugin' before any other plugins in your app/build.gradle file.
  3. Add implementation 'play-services-base version:17.6.0 to your dependencies { ... } section.
    • You may see the error in the future however, since this is an exact version that can change. Or you may need to update it for other reasons

If one of these fixes your issue let us know which one so I can help other. Also it will still be useful to post your build.gradle files so we can reproduce and attempt other solutions to recommend later.

@rigo-ptz
Copy link
Author

Hi! Here's my root build.gradle


buildscript {
    ext.kotlin_version = '1.5.21'
    repositories {
        google()
        mavenCentral()
        // https://github.com/JakeWharton/butterknife/issues/963
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        // aws appsync
        maven { url "https://plugins.gradle.org/m2/" }
        // OneSignal
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "io.realm:realm-gradle-plugin:6.1.0"
        classpath('com.google.firebase:firebase-plugins:2.0.0') {
            // https://issuetracker.google.com/issues/38419426#comment8
            exclude group: 'com.google.guava', module: 'guava-jdk5'
        }
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
        classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0"
        classpath 'com.bugsnag:bugsnag-android-gradle-plugin:7.0.0-beta01'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"

        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
        //Tap and pay - android provisioning
        classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.2'

        // Apollo client
        classpath("com.apollographql.apollo:apollo-gradle-plugin:2.5.9")

        classpath("com.github.bjoernq:unmockplugin:0.7.8")

        // OneSignal
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        mavenLocal()
        maven { url "https://www.jitpack.io" }
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
        maven { url "https://maven.google.com" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        maven { url "https://cdn.veriff.me/android/" } // Veriff SDK
        // aws appsync
        maven { url "https://plugins.gradle.org/m2/" }
    }
}

subprojects {
    tasks.withType(Test) {
        maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
    }
}

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

apply from: rootProject.file('dependencies.gradle')
apply from: rootProject.file('projectDependencyGraph.gradle')

and the one from the app module:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: "kotlin-android-extensions"
apply plugin: 'realm-android'
apply plugin: "org.sonarqube"
apply from: 'versioning.gradle'
apply from: './../whim.gradle'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: "com.diffplug.gradle.spotless"
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'de.mobilej.unmock'
apply plugin: 'project-report'

// Please keep this at the bottom for compilation
// https://docs.bugsnag.com/build-integrations/gradle/#additional-configuration/
apply plugin: 'com.bugsnag.android.gradle'

//Tap and pay - provisioning
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

// https://firebase.google.com/docs/android/setup#add_the_sdk
apply plugin: 'com.google.gms.google-services'

apply plugin: 'com.google.firebase.crashlytics'

kapt {
    correctErrorTypes = true
}

...

dependencies {
    implementation "com.google.android.gms:play-services-base:${playServicesBase}",
    implementation "com.google.android.gms:play-services-maps:${playServicesMaps}",
    implementation "com.google.android.gms:play-services-auth:${playServicesAuth}",
    implementation "com.google.android.gms:play-services-wallet:${playServicesWallet}",
    implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
}

from ext:

playServicesBase = '17.6.0'
    playServicesMaps = '17.0.1'
    playServicesLocation = '18.0.0'
    playServicesAuth = '19.2.0'
    playServicesWallet = '18.1.3' // Google Pay

All three points are fulfilled, but it still doesn't work. Can this happen because of the apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'?

@rigo-ptz
Copy link
Author

rigo-ptz commented Nov 2, 2021

Well, these changes helped to eliminate the problem:

  1. Removing classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.2' from buildscript.dependencies
  2. Removing apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' from app-level gradle file.
    Thank you!

@jkasten2
Copy link
Member

jkasten2 commented Nov 3, 2021

@rigo-ptz Thanks for pointing that out! I believe the root issue is due to an incompatibility with strict-version-matcher-plugin and onesignal-gradle-plugin. Since onesignal-gradle-plugin will bump versions higher if it finds something incompatible with OneSignal. The version change might be done in a way that strict-version-matcher-plugin doesn't detect correctly, or maybe strict-version-matcher-plugin does not handle version ranges in correctly in some cases.

I did find the exact line where this message is being printed from, it's possible this could be helpful in finding a solution to get them working together in the future:
https://github.com/google/play-services-plugins/blob/8609452db3f23989797eae3e2494aff80ffac311/strict-version-matcher-plugin/src/main/java/com/google/android/gms/dependencies/DependencyInspector.java#L296

@rigo-ptz
Copy link
Author

rigo-ptz commented Nov 5, 2021

@jkasten2 Thank you! I think you can close this issue.

By the way, I found another way to reproduce this even without strict-version-matcher-plugin. I keep all analytical libs (firebase, appsflyer, onesignal ...) in a separate android module. But in order to be able to init these libraries from the application class, I add dependencies there using api "foo.bar:0.0.0". When I add OneSignal, I get the same error

In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.0.
0, 17.6.99]", but isn't being resolved to that version. 

To fix this, I had to add googleServices { disableVersionCheck = true } to the app-level gradle.

@jkasten2
Copy link
Member

This has now been fixed in the 4.6.4 release when using Gradle 6 or newer.
https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/4.6.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants