问题
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'
回答1:
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:
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
回答3:
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.
回答4:
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
}
来源:https://stackoverflow.com/questions/41693915/cordova-firebase-plugin-notification-cannot-add-task-processdebuggoogleservi