OneSignal / OneSignal-Gradle-Plugin

Use with OneSignal-Android-SDK to help integrate it into your Android Studio or Gradle project. https://onesignal.com
Other
64 stars 17 forks source link

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0). #94

Closed zhaoaoranke closed 4 years ago

zhaoaoranke commented 5 years ago

Hi, i am getting this error when resync gradle. Please help

using on implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]' Https://status.bintray.com/ It seems that there is no problem, Please help me, it has been bothering me for a long time.

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[10.2.1, 12.1.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[15.0.0, 16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[10.2.1, 12.1.0). Show Details Affected Modules: app

jkasten2 commented 5 years ago

@zhaoaoranke If your project can't find com.google.android.gms versions 15 or higher this is normally due to google() and jcenter() being defined out of order in your build.gradle. Please follow this answer to fix the issue. https://stackoverflow.com/a/51139617/1244574

If this does not help please provide a more complete log.

jkasten2 commented 5 years ago

Closing issue due to inactivity.

SArsalanK commented 4 years ago

@jkasten2 .. The solution that you provided did not help. I had to remove OneSignal SDK from the project to get rid of the problem. Please reopen this issue. Thanks. :(

**_ ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0). Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]. Show Details Affected Modules: app _**

miltonrincon commented 4 years ago

I am facing this issue, appears on my project form one day to another with no one configuration changes @SArsalanK could you resolve the problem?

jkasten2 commented 4 years ago

@miltonrincon @SArsalanK Please provide a bare bones as possible example project reproduce the issue and we can try to reproduce the issue on our end.

miltonrincon commented 4 years ago

This my build.gradle module app

`buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.6'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.apollographql.apollo'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "APPLICATION_ID"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 52
        versionName "2.0.0"
        flavorDimensions "default"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [
                onesignal_app_id               : 'ONE_SIGNAL_ID',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            minifyEnabled false
            debuggable true
        }
    }
    productFlavors {
        dev {
            applicationIdSuffix ".dev"
        }
        qa {
            applicationIdSuffix ".qa"
        }
        prod {}
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    apollo {
        generateKotlinModels.set(false) // or false for Java models
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'androidx.test:core:1.2.0'
    testImplementation 'org.mockito:mockito-core:2.28.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'

    implementation 'com.google.android.material:material:1.1.0'

    implementation 'com.google.android.gms:play-services-vision:20.0.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.maps:google-maps-services:0.2.5'
    implementation 'com.google.maps.android:android-maps-utils:0.6.2'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.google.firebase:firebase-core:17.3.0'
    implementation 'com.google.firebase:firebase-messaging:20.1.0' //Do not update this, conflicts with version 20.1.4 leave 20.1.0
    implementation 'com.google.android.gms:play-services-maps:17.0.0'

    implementation 'io.socket:socket.io-client:1.0.0'
    implementation 'com.github.ybq:AndroidSpinKit:v1.0.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.faruktoptas:FancyShowCaseView:1.1.0'
    implementation 'xyz.belvi.mobilevision:barcodescanner:2.0.3'
    implementation 'com.onesignal:OneSignal:3.13.0'
    implementation 'com.ramotion.circlemenu:circle-menu:0.3.2'
    implementation 'com.google.guava:guava:27.0.1-android'
    implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.11.0'
    implementation 'com.onesignal:OneSignal:3.13.0'

    implementation "android.arch.lifecycle:extensions:1.1.1"
    implementation 'io.sentry:sentry-android:1.7.27'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    implementation 'com.uxcam:uxcam:3.1.12@aar'

    implementation 'com.github.lecho:hellocharts-library:1.5.8@aar'
    implementation 'com.nikhilpanju.recyclerviewenhanced:recyclerviewenhanced:1.1.0'
    implementation 'com.sothree.slidinguppanel:library:3.4.0'

    implementation group: 'com.zendesk', name: 'support', version: '2.3.1'

    implementation("com.apollographql.apollo:apollo-runtime:1.4.5")

    compileOnly("org.jetbrains:annotations:13.0")
    testCompileOnly("org.jetbrains:annotations:13.0")

    implementation("com.squareup.okhttp3:okhttp:4.5.0")
    implementation 'com.google.android.gms:play-services-ads:19.1.0'
}

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

This is the configuration of the project:

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com/"}
        maven {url 'https://maven.fabric.io/public'}
        maven {url 'https://sdk.uxcam.com/android/'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.31.2'
        classpath("com.apollographql.apollo:apollo-gradle-plugin:1.4.5")
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com/"}
        maven { url "https://jitpack.io" }
        maven {url 'https://maven.fabric.io/public'}
        maven {url 'https://sdk.uxcam.com/android/'}
        maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
    }
}

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

`

miltonrincon commented 4 years ago

Finally I resolved it. I had to change the build.gradle(:app) implementation to

implementation ('com.onesignal:OneSignal:3.13.0') { exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-location' exclude group: 'com.google.android.gms', module: 'play-services-ads-identifier' exclude group: 'com.google.firebase', module: 'firebase-messaging' } implementation 'com.google.android.gms:play-services-vision:15.0.0'

in the same file i had to add maven { url 'https://maven.google.com' }

The result is:

`buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } maven { url 'https://maven.google.com' } } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.6' } }

Finally y has to go to the build.gradle module project and downgrade the Android Gradle plugin to 3.6.2

classpath 'com.android.tools.build:gradle:3.6.2'

Thanks to @RodrigoPulidoG

jkasten2 commented 4 years ago

@miltonrincon Thanks for the full build.gradle files. I was able to reproduce the issue with them.

The issue no longer happens if I remove maven {url 'https://sdk.uxcam.com/android/'} and implementation 'com.uxcam:uxcam:3.1.12@aar'.

It seems UXCam has a configuration issue that is triggering a Gradle 5.6.4 bug where it can't find dependencies when other repositories have an issue. Also notice that when maven {url 'https://sdk.uxcam.com/android/'} is present it takes a long time to sync this is something that UXCam should fix.

However if you do upgrade to Gradle 6.0 the this will fix the build issue (sync is still slow due to UXCam's issue). To upgrade Gradle update the version number in your project's gradle\wrapper\gradle-wrapper.properties file.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
SArsalanK commented 4 years ago

I forgot to add the plugin apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' on the top of build.Gradle (app) file of my project which lead to this compile failure.

saqibskvip commented 4 years ago

Replace Update the Classpath:

classpath 'com.android.tools.build:gradle:3.6.4'