Cordova-plugin-fcm-with-dependecy-updated issue Could not create task ':app:processDebugGoogleServices'

Hello to all

I’m struggling with this issue, for fcm integration i’ve followed this tutorial:

https://www.positronx.io/ionic-firebase-fcm-push-notification-tutorial-with-example/

all go well till to the compilation, when i received first a warning:

FCMPlugin: Support for Gradle v4 or lower is deprecated. Please upgrade to a newer version.

and successively the build fail with this message:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:app’.
    Could not create task ‘:app:processDebugGoogleServices’.
    Cannot create a proxy class for abstract class ‘GoogleServicesTask’.

my ionic info are:

Ionic:

Ionic CLI : 5.4.2 (C:\Users\Programmazione\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.2, (and 10 other plugins)

Utility:

cordova-res : 0.15.1
native-run : 0.2.9

System:

Android SDK Tools : 26.1.1 (C:\Users\Programmazione\AppData\Local\Android\Sdk)
NodeJS : v10.16.3 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10

Thanks in advance for any suggestion

I partially solved my problem in a sample project i’ve proceeded to update Cordova to latest version with the following command:

npm install -g cordova@latest

successively I removed the native fcm plugin:

npm uninstall @ionic-native/fcm

I modified the code in app.module.ts e app.component.ts

with the following code

app.module.ts:

import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;

providers: [

FCM,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
SQLite,
SQLitePorter,
Map
],

app.component.ts in initializeapp method:

import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;

   // subscribe to a topic
   // this.fcm.subscribeToTopic('Deals');

  // get FCM token
  this.fcm.getToken().then(token => {
    console.log("Gettoken: ", token);
  });

  // ionic push notification example
  this.fcm.onNotification().subscribe(data => {
    console.log(data);
    if (data.wasTapped) {
      console.log('Received in background');
    } else {
      this.alertCtrl.create({
        header: data.title,
        message: data.body,
        backdropDismiss: false,
        buttons: [{
          text: 'OK',
          role: 'cancel',
          handler: () => {
            console.log('Notifica confermata!');
          }
        }]
      })
        .then(alert => {
          alert.present();
        });
      console.log('Received in foreground');
    }
  });      

  // refresh the FCM token
  this.fcm.onTokenRefresh().subscribe(token => {
    console.log("OntokenRefresh: ", token);
  });

  // unsubscribe from a topic
  // this.fcm.unsubscribeFromTopic('offers');

Successively i’ve upgraded gradle version from 4.10.3 to 5.6.2 modifying the zip file name in [myproject]/platform/android/cordova/lib/builders/ProjectBuilder.js at the line:

var distributionUrl = process.env[‘CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL’] || >‘https\://services.gradle.org/distributions/gradle-5.6.2-all.zip’;

Hope this will help somebody, but now in the final project i’ve another compilation error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:processDebugManifest’.

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to element at AndroidManifest.xml:5:5-32:19 to override.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

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

BUILD FAILED in 16s
[ERROR] An error occurred while running subprocess cordova.

    cordova.cmd build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

There is someone that can help me, thanks in advance for any suggestion.

I solved the last issue following this answer on stackoverflow: angular - Ionic4: Execution failed for task ':app:processDebugManifest' - Stack Overflow

in particular i’ve installed this two plugins:

ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter

And executed this command:

cordova clean android

Then I rebuilded all and now is working even in the final project

Thanks anyway to all