Unable to build apk after adding firebase-analytics[Ionic, Cordova]

Viewed 127

I am getting error when I try to build apk after adding firebase-analytics. It is showing error in console is

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\sampleproject\platforms\android\app\build.gradle' line: 428

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > Cannot add extension with name 'googleServices', as there is an extension already registered with that name.

* 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 6s
Command failed with exit code 1: D:\sampleproject\platforms\android\gradlew cdvBuildDebug -b D:\sampleproject\platforms\android\build.gradle
[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.

The file googleservices is already present in my project before. As I am using Firebase authentication before in my project. Now the issue is, I can't edit the Gradle file as I am using Cordova to build the Apk. I also gone through other stackoverflow question and answers, I commented out

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

in gradle but this is not the proper way to solve this problem.

Below this I am mentioning all the extensions I had in my project.

  1. "@ionic-native/firebase-analytics": "^5.36.0",
  2. "@ionic-native/google-plus": "^5.28.0",
  3. "firebase": "^7.19.1",
  4. "google-auth-library": "^6.0.6",
  5. "cordova-plugin-firebase-analytics": "^6.1.0",
  6. "cordova-plugin-firebase-lib": "^5.1.1",
    For more clarification I attached the screenshot.console error log Thank you in advance.
0 Answers
Related