fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 990 forks source link

Cannot add task ':app:processDebugGoogleServices' as a task with that name already exists #578

Open EmilienRamos opened 5 years ago

EmilienRamos commented 5 years ago

Hey !

I download ionic cordova plugin add cordova-plugin-fcm in order to send and to receive push notification from device to Firebase.

Unfortunately, when I launch ionic cordova run android --device, I got this issue :

BUILD FAILED in 1s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot add task ':app:processDebugGoogleServices' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

This is my /platforms/android/cordova-plugin-fcm/FCMPlugin.gradle :

buildscript {
    repositories {
            jcenter()
            mavenLocal()
        }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Does someone have an idea ?

diffTed commented 5 years ago

Hi,

change the last line of code ( /platforms/android/cordova-plugin-fcm/FCMPlugin.gradle): apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

to this:

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

and build will work.

anteAdamovic commented 5 years ago

Any update on this ? Facing the same issue.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot add task ':app:processDebugGoogleServices' as a task with that name already exists.
firmanpurnama commented 4 years ago

yes i have the same problem

arthurduarte1 commented 4 years ago

Same problem here.

AmnahAlabdulal commented 4 years ago

any update ? I have the same issue

pawan-logiciel commented 4 years ago

What works for me was changing the line:

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

in platforms\android\cordova-plugin-fcm-with-dependecy-updated

to this:

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

or if you have install phonegap-plugin-push then remove it and try again

invincibleP commented 4 years ago

Hello all! I am facing one serious issue after adding below plugin (which is very essential for me)

$ ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated $ npm install @ionic-native/fcm

Build failed

I have already installed:

$ ionic cordova plugin add cordova-plugin-firebase-authentication $ npm install @ionic-native/firebase-authentication

and i could build it after adding this plugin..

Is this versioning issue? if yes how to resolve this? Can anyone guide?

My project files

app-FCMPlugin.gradle

buildscript { repositories { mavenCentral() jcenter() mavenLocal() } dependencies { classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.google.gms:google-services:3.1.+' } } repositories { mavenCentral() jcenter() } dependencies { compile 'com.google.firebase:firebase-core:10.+' } // apply plugin: 'com.google.gms.google-services' // class must be used instead of id(string) to be able to apply plugin from non-root gradle file apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

build.gradle

buildscript { repositories { google() jcenter() }

dependencies {
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

    classpath 'com.android.tools.build:gradle:3.3.0'
}

}

allprojects { repositories { google() jcenter() }

//This replaces project.properties w.r.t. build settings
project.ext {
  defaultBuildToolsVersion="28.0.3" //String
  defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
  defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
  defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
}

}

task clean(type: Delete) { delete rootProject.buildDir }

package.json

"name": "DevApp", "version": "0.0.1", "author": "Ionic Framework", "homepage": "https://ionicframework.com/", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^7.2.2", "@angular/cdk": "^7.3.7", "@angular/common": "^7.2.2", "@angular/core": "^7.2.2", "@angular/flex-layout": "^7.0.0-beta.24", "@angular/forms": "^7.2.2", "@angular/http": "^7.2.2", "@angular/material": "^7.3.7", "@angular/platform-browser": "^7.2.2", "@angular/platform-browser-dynamic": "^7.2.2", "@angular/router": "^7.2.2", "@fortawesome/angular-fontawesome": "^0.3.0", "@fortawesome/fontawesome-svg-core": "^1.2.19", "@fortawesome/free-solid-svg-icons": "^5.9.0", "@ionic-native/android-full-screen": "^5.9.0", "@ionic-native/android-permissions": "^5.10.0", "@ionic-native/calendar": "^5.10.0", "@ionic-native/contacts": "^5.10.0", "@ionic-native/core": "^5.0.0", "@ionic-native/device": "^5.8.0", "@ionic-native/fcm": "^5.11.0", "@ionic-native/file": "^5.9.0", "@ionic-native/file-opener": "^5.10.0", "@ionic-native/file-transfer": "^5.9.0", "@ionic-native/firebase-authentication": "^5.11.0", "@ionic-native/geolocation": "^5.8.0", "@ionic-native/http": "^5.8.0", "@ionic-native/local-notifications": "^5.10.0", "@ionic-native/photo-viewer": "^5.10.0", "@ionic-native/social-sharing": "^5.10.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic-native/youtube-video-player": "^5.8.0", "@ionic/angular": "^4.1.0", "@ionic/storage": "^2.2.0", "color": "^3.1.2", "com-sarriaroman-photoviewer": "1.2.4", "cordova-android": "8.0.0", "cordova-plugin-advanced-http": "2.1.1", "cordova-plugin-android-permissions": "1.0.0", "cordova-plugin-badge": "0.8.8", "cordova-plugin-calendar": "5.1.4", "cordova-plugin-contacts": "3.0.1", "cordova-plugin-fcm-with-dependecy-updated": "2.4.0", "cordova-plugin-file": "^6.0.1", "cordova-plugin-file-opener2": "2.2.0", "cordova-plugin-file-transfer": "1.7.1", "cordova-plugin-firebase-authentication": "3.0.0", "cordova-plugin-fullscreen": "1.2.0", "cordova-plugin-geolocation": "4.0.1", "cordova-plugin-local-notification": "0.9.0-beta.2", "cordova-plugin-native-keyboard": "^2.0.3", "cordova-plugin-x-socialsharing": "5.4.7", "cordova-plugin-youtube-video-player": "2.3.0", "cordova-sqlite-storage": "3.2.0", "cordova-support-android-plugin": "1.0.1", "cordova-support-google-services": "1.3.1", "core-js": "^2.5.4", "es6-promise-plugin": "4.2.2", "hammerjs": "^2.0.8", "ionic4-date-picker": "^0.1.0", "moment": "^2.24.0", "ngx-audio-player": "^7.1.3", "ngx-moment": "^3.4.0", "rxjs": "~6.5.1", "tslib": "^1.9.0", "zone.js": "~0.8.29" }, "devDependencies": { "@angular-devkit/architect": "~0.13.8", "@angular-devkit/build-angular": "~0.13.8", "@angular-devkit/core": "~7.3.8", "@angular-devkit/schematics": "~7.3.8", "@angular/cli": "~7.3.8", "@angular/compiler": "~7.2.2", "@angular/compiler-cli": "~7.2.2", "@angular/language-service": "~7.2.2", "@ionic/angular-toolkit": "~1.5.1", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~12.0.0", "codelyzer": "~4.5.0", "cordova-plugin-device": "^2.0.2", "cordova-plugin-ionic-webview": "^4.1.0", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.4.0", "ts-node": "~8.1.0", "tslint": "~5.17.0", "typescript": "~3.1.6" }, "description": "An Ionic project", "cordova": { "plugins": { "cordova-plugin-advanced-http": {}, "cordova-plugin-whitelist": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" }, "cordova-plugin-youtube-video-player": {}, "cordova-sqlite-storage": {}, "cordova-plugin-geolocation": {}, "cordova-plugin-file": {}, "cordova-plugin-file-transfer": {}, "cordova-plugin-file-opener2": {}, "cordova-plugin-fullscreen": {}, "cordova-plugin-calendar": {}, "cordova-plugin-contacts": {}, "cordova-plugin-x-socialsharing": { "ANDROID_SUPPORT_V4_VERSION": "24.1.1+" }, "cordova-plugin-local-notification": {}, "cordova-plugin-android-permissions": {}, "com-sarriaroman-photoviewer": {}, "cordova-plugin-native-keyboard": { "LICENSE": "TRIAL", "LIC_ANDROID": "TRIAL" }, "cordova-plugin-fcm-with-dependecy-updated": {}, "cordova-plugin-firebase-authentication": { "FIREBASE_AUTH_VERSION": "18.0.+" } }, "platforms": [ "android" ] } }

app.build.gradle

buildscript { repositories { google() jcenter() mavenCentral() }

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

}

// use postBuildExtras to make sure the plugin is applied after // cdvPluginPostBuildExtras. Therefore if googleServices is added // to cdvPluginPostBuildExtras somewhere else, the plugin execution // will be skipped and project build will be successfull ext.postBuildExtras = { if (project.extensions.findByName('googleServices') == null) { // apply plugin: 'com.google.gms.google-services' // class must be used instead of id(string) to be able to apply plugin from non-root gradle file apply plugin: com.google.gms.googleservices.GoogleServicesPlugin } }

A prompt response would be appreciated!

pawan-logiciel commented 4 years ago

@invincibleP review this it's might help you https://stackoverflow.com/questions/55844174/cannot-add-task-processdebuggoogleservices-as-a-task-with-that-name-already-ex

invincibleP commented 4 years ago

@pawan-logiciel thanks but it's not working. I tried it. I don't think its a stable plugin!

MarcosRibeiroJesus commented 4 years ago

Same here...

Khaledalien commented 4 years ago

I'm struggling with ionic after adding any plugin. I hate ionic

dashko commented 4 years ago

None of the solutions worked for me.

@K-Desu Indeed, any change in plugins results in errors, and hours of googling...

RanajitManna commented 4 years ago

A problem occurred configuring project ':app'.

org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException: Cannot add task 'processDebugGoogleServices' as a task with that name already exists.

gildonei commented 4 years ago

Does anyone solved this issue?

pawan-logiciel commented 4 years ago

@RanajitManna i think it comes due to update of google services you can try this by uninstall cordova-support-google-services plugin and add it from https://github.com/chemerisuk/cordova-support-google-services here i think that might solve your problem

gildonei commented 4 years ago

I just got able to "solve" by creating an empty project and compiling it from scratch and after that add plugins one by one until complete the project, the final code was exactly the same from before the bug.

abdullahbhojani commented 2 years ago

Hi Please make sure that you are using only this package make sure to uninstall or remove the previous packages related to FCM. I was using firebase-x so first I removed firebase-x than I installed cordova-plugin-fcm-with-dependecy-updated. this works for me

abdullahbhojani commented 2 years ago

Hi Please make sure that you are using only this package make sure to uninstall or remove the previous packages related to FCM. I was using firebase-x so first I removed firebase-x than I installed cordova-plugin-fcm-with-dependecy-updated. this works for me