Cannot add extension with name 'googleServices', as there is an extension already registered with that name. – Moodle mobile app – Ionic – FCM

Issue

I am trying to add Notification feature in Moodle Mobile App using Firebase Cloud Messaging, and I am getting an error while building the Ionic app.

cordova build android
Conflict found, edit-config changes from config.xml will overwrite plugin.xml changes
Removing permission "android.permission.REQUEST_INSTALL_PACKAGES" from AndroidManifest.xml
cordova-plugin-androidx-adapter: Processed 122 source files in 3077ms
[cordova-plugin-push::before-compile] skipping before_compile hookscript.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/home/egp/Android/Sdk (recommended setting)
ANDROID_HOME=/home/egp/Android/Sdk (DEPRECATED)
Using Android SDK: /home/egp/Android/Sdk
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use –status for details

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 41s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 busy and 2 incompatible and 1 stopped Daemons could not be reused, use –status for details

Configure project :app
Adding classpath: com.google.gms:google-services:4.3.10
Warning: The ‘kotlin-android-extensions’ Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the ‘kotlin-parcelize’ plugin.
WARNING:: Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

FAILURE: Build failed with an exception.

Where:
Build file ‘/home/egp/moodleapp_with_notification_github/moodleapp/platforms/android/app/build.gradle’ line: 352

What went wrong:
A problem occurred evaluating project ‘:app’.
Failed to apply plugin ‘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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 11s
Command failed with exit code 1: /home/egp/moodleapp_with_notification_github/moodleapp/platforms/android/gradlew cdvBuildDebug -b /home/egp/moodleapp_with_notification_github/moodleapp/platforms/android/build.gradle
[ERROR] An error occurred while running subprocess cordova.

cordova build android exited with exit code 1.

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

Solution

It looks like the notifications module you are loading adds googleServices but your app already has this added.

Find the line that goes like:

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

And comment it out by adding // in front. Then rebuild the project, the error should go away!

Alternatively, disable the platform from adding the GoogleServicePlugin by changing this value in config.xml to false.

<preference name="GradlePluginGoogleServicesEnabled" value="true" />

This will prevent the build process from adding the google service plugin which you plugin already adds.

Answered By – Saifur Rahman Mohsin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published