11

i'm trying to add Google Firebase Notifications on my Phonegap Cordova app, built with Ionic. I've already installed successfully a Google Plus plugin for login (i think this would be a useful info).

I only need this Firebase plugin to complete my job but i've been stopped by this error when i build my app for Android.

A problem occurred configuring root project 'android'. Cannot add task ':processDebugGoogleServices' as a task with that name already exists.

I follow this tutorial for setup Cordova Plugin Firebase Cloud Messaging For Android

Here is my build.gradle file edited as the tutorial said:

apply plugin: 'com.android.application'

  buildscript {
    repositories {
       mavenCentral()
       jcenter()
    }


  dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
    classpath 'com.google.gms:google-services:3.0.0'
  }
}

--------


dependencies {
   compile fileTree(dir: 'libs', include: '*.jar')
   // SUB-PROJECT DEPENDENCIES START
   debugCompile(project(path: "CordovaLib", configuration: "debug"))
   releaseCompile(project(path: "CordovaLib", configuration: "release"))
   compile "com.google.android.gms:play-services-plus:9.2.0"
   compile "com.google.android.gms:play-services-identity:9.2.0"
   compile "com.android.support:support-v4:+"
   compile "com.android.support:appcompat-v7:+"
   compile "com.android.support:appcompat-v7:23.2.1"
   compile "com.google.firebase:firebase-messaging:9.0.2"
   // SUB-PROJECT DEPENDENCIES END
}
apply plugin: 'com.google.gms.google-services'

4 Answers 4

6

Had the same issue. It appears com.android.application already includes google-services. To fix it remove:

apply plugin: 'com.google.gms.google-services'
2
  • I had a similar problem...I cannot remove it as then push & dynamic linking will not work...Any alternative suggestion Apr 4, 2019 at 13:43
  • as i ionic add "cordova plugin add cordova-plugin-fcm-with-dependecy-updated" plugin i face this problem.. and i am unable to get rid off...
    – bunny
    Apr 25, 2019 at 15:52
0

use classpath 'com.android.tools.build:gradle:2.2.2' instead of classpath 'com.android.tools.build:gradle:2.2.0'

and use dependency

compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'

make sure that you add the google_service json file in your app folder

2
  • Moreover i see that when i try to build, the file build.gradle lost my changes and back to original version i shared before.
    – Francesco
    Jan 17, 2017 at 10:21
  • i follow the code from simplifiedcoding.net/firebase-cloud-messaging-tutorial-android its perfectly work for me but in new android update we need to use the above dependency and classpath i posted above otherwise it will show error. in my opinion no need to use Cordova app plugin. if you are using firebase you need to import google sign using firebase.
    – Sam
    Jan 17, 2017 at 11:50
0

I've find out a solution.

  • remove platform android from project
  • add again platform android (which reload all dependencies and plugin)
  • repeat all steps on that guide (setup Firebase notifications)

Everything works well! The problem was on a conflict between Google Plus plugin and Firebase which requires both same services.

0

fcmplugin.gradle and build.gradle need google-services

so, change this:

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

to this:

ext.postBuilderExtras = { 
  apply plugin : com.google.gms.googleservices.GoogleServicesPlugin
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.