android can't add one singnal

2019-08-30 06:43发布

问题:

I am trying to one signal to my project and i add dependencies like this

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

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

}

and in my build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'io.fabric.tools:gradle:1.24.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'http://jhoobin.abroid.com/repo/' }
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
        google()
    }

}

but i keep getting error when i sync the gradle

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not find any version that matches com.google.android.gms:play-services:15.+. Open File
Show Details

what is wrong with my code ?

回答1:

These are my gradles. This is my :app gradle

//noinspection GradleCompatible
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.app.app"
        manifestPlaceholders = [onesignal_app_id: "APP_ID_HERE",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "PROJECT_NUMBER_HERE"]
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/commons-io-2.4.jar')
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.onesignal:OneSignal:3.+@aar'
    // Required for OneSignal, even if you have added FCM.
    compile 'com.google.android.gms:play-services-gcm:10.2.0'
    testCompile 'junit:junit:4.12'
}

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

My main projects 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
}