error when apply plugin: 'com.google.gms.google-services'
Asked Answered
N

11

23

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:1.+@aar'
    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()
    }
}
Ninetieth answered 10/2, 2016 at 9:56 Comment(1)
post your gradle full trace.Magnoliamagnoliaceous
O
19

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:+'

Do

compile 'com.google.android.gms:play-services:8.4.0'
Oneiric answered 10/2, 2016 at 10:3 Comment(0)
B
17

Need to enter the following entry in both gradle:

  1. Add the following to the @project level gradle file:

    classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
    
  2. Add the following to the @app level gradle file:

    // Dependency for Google Sign-In
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    
  3. Add plugin:

    apply plugin: 'com.google.gms.google-services'
    
Bertiebertila answered 22/9, 2016 at 9:41 Comment(1)
I'm working with ionic/cordova. Can you explain what is meant about project level and app level my build.gradle is at myApp/platforms/android/build.gradle. But there is also build.gradle at myApp/platforms/android/CordovaLib/build.gradleRivero
H
3

Add the following to the @project level gradle file:

    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.google.gms:google-services:3.0.0'
Hugohugon answered 30/3, 2017 at 2:40 Comment(0)
K
2

Replace the line compile 'com.google.android.gms:play-services-gcm:+'

with the following compile 'com.google.android.gms:play-services-gcm:8.4.0'

in the application build.gradle file.

Karmen answered 10/2, 2016 at 10:5 Comment(0)
K
2

As many ppl said, I've added "classpath 'com.google.gms:google-services:3.0.0'" in the project level gradle.

But, I encountered another error saying "File google-services.json is missing from module root folder.". Eventually, I needed to set up a project via the following link. https://developers.google.com/mobile/add?platform=android

After setting up a project and it took me to go to Firebase console. In that page, I was able to download google-service.json file which was essential to solve this issue.

Drag and drop that JSON file under your project's '/app' folder.

It took me an hour to figure it out. I hope it's helpful for someone.

Kink answered 6/4, 2017 at 7:59 Comment(0)
F
1

Please take note that the classpath has been updated. The new classpath entry is 'com.google.gms:google-services:4.3.15' in android/settings.gradle

Faunus answered 8/8, 2023 at 15:57 Comment(2)
Upvoted, since this was helpful to me. It would be even more helpful with copyable text and a link to the info.Halmahera
For future reference: It's in android/settings.gradleLoafer
N
0

I was having this exact issue, and the following fixed it.. go to platforms>android>project.properties and edit the lines

cordova.system.library.5=com.google.android.gms:play-services-auth:+
cordova.system.library.6=com.google.android.gms:play-services-identity:+

to

cordova.system.library.5=com.google.android.gms:play-services-auth:11.0.1
cordova.system.library.6=com.google.android.gms:play-services-identity:11.0.1

It is said that # Do not modify this file -- YOUR CHANGES WILL BE ERASED! But this fixed my issue

Nelrsa answered 9/8, 2017 at 22:46 Comment(0)
S
0

Change following code in project.properties from:

cordova.system.library.2=com.google.android.gms:play-services-gcm:+
cordova.system.library.3=com.google.android.gms:play-services-location:+

to

cordova.system.library.2=com.google.android.gms:play-services-gcm:11.0.1
cordova.system.library.3=com.google.android.gms:play-services-location:11.0.1

and add google-service.json file to app module

Solfeggio answered 20/8, 2017 at 5:6 Comment(0)
R
0

Sometimes, you have to update your REALM-PLUGIN and you need to write this in Top-Level Gradle (Project:Gradle), copy paste below "classpath" line:

buildscript {
  ... 
  dependencies {
    classpath 'io.realm:realm-gradle-plugin:7.0.0' //<--Your answer.
  }
}
Ramshackle answered 5/8, 2020 at 18:39 Comment(0)
D
0

You put line apply plugin: 'com.google.gms.google-services' twice in line 0 and line 49 simply remove one line

Diplegia answered 16/9, 2021 at 16:30 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewHowell
Z
0

I have removed this line from gradle.properties. It work for me android:requestLegacyExternalStorage="true"

Zachariahzacharias answered 17/4, 2024 at 18:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.