Android – error when apply plugin: ‘com.google.gms.google-services’

android, google-analytics-firebase

I followed google documentation to integrate my app to Google Analytics.
But when adding

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

and building my app, I encountered this error:

Error:(49, 0) For input string: "+"

These are the settings I used in the build.gradle of my application:

apply plugin: 'com.android.application'android {    compileSdkVersion 22    buildToolsVersion "22.0.1"    defaultConfig {        applicationId "com.myapp.xyz"        manifestPlaceholders = [            manifestApplicationId : "${applicationId}",            onesignal_app_id : "ccd48c54-2069-41f9-8ff7-54c7a12f2d18a",            onesignal_google_project_number: "306632981237"        ]        minSdkVersion 15        targetSdkVersion 22        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'),            'proguard-rules.pro'        }    }}repositories {    mavenCentral()}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    // compile 'com.android.support:appcompat-v7:22.2.1'    compile project(':facebook')    compile 'com.android.support:design:22.2.1'    compile 'com.android.support:palette-v7:22.2.1'    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'    compile 'com.android.support:appcompat-v7:22.2.1'    compile 'com.android.support:support-v4:22.2.1'    compile 'com.onesignal:OneSignal:[email protected]'    compile 'com.google.android.gms:play-services-gcm:+'    compile 'com.google.android.gms:play-services:8.4.0'    compile 'com.google.android.gms:play-services-analytics:8.4.0'}apply plugin: 'com.google.gms.google-services'

These are the setting in build.gradle application:

buildscript {    repositories {        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:1.2.3'        classpath 'com.google.gms:google-services:2.0.0-alpha6'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        jcenter()    }}

Best Solution

At first you should call

    dependencies {    classpath 'com.android.tools.build:gradle:1.5.0'    classpath 'com.google.gms:google-services:2.0.0-alpha2'}

Don't (Avoid calling +)

compile 'com.google.android.gms:play-services-gcm:+'     compile 'com.google.android.gms:play-services:8.4.0'

Do

     compile 'com.google.android.gms:play-services:8.4.0'