Ionic Native FCM Plugin Installation Breaks Android Build

I have a working Angular 8, Ionic 4 application that breaks as soon as I install the fcm Cordova plugin for push notifications. I’m getting this error message from Android Studio:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':capacitor-cordova-android-plugins'.<116 internal calls>

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.android.build.gradle.internal.crash.ExternalApiUsageException: java.lang.NullPointerException
	at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:130)
	at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:725)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:82)
	at com.android.build.gradle.BasePlugin.lambda$createTasks$5(BasePlugin.java:615)
	at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt:37)
	at com.android.build.gradle.internal.crash.CrashReporting$afterEvaluate$1.execute(crash_reporting.kt)<26 internal calls>

... 116 more
Caused by: java.lang.NullPointerException
at com.google.gms.googleservices.GoogleServicesPlugin.handleVariant(GoogleServicesPlugin.groovy:206)
at com.google.gms.googleservices.GoogleServicesPlugin$_setupPlugin_closure6.doCall(GoogleServicesPlugin.groovy:148)
at com.android.build.gradle.LibraryExtension.addVariant(LibraryExtension.java:90)
	at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:127)
	... 147 more

Android Studio is also giving me this popup message, but I’m pretty sure this shouldn’t be a problem when compiling with Capacitor

Compilation is not supported for following modules: capacitor-cordova-android-plugins. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

The only thing that changed from a WORKING BUILD to this error were these commands as listed in the documentation

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

Then

ionic capacitor update
ionic capacitor sync
ionic capacitor run android

and I received this error. As far as I can tell, this is a bug in the plugin installation and not my error. But, I am still trying to implement Firebase Cloud Messaging for mobile on my app. Please help with any alternatives.

Issue with the same problem:


Thanks!

i have also same problem, i able to solve it.
click this link

dont use capacitor, use cordova