Google services version conflict (Maps / FCM)

Can anyone help me? I’m kind off lost. I’m using the FCM plugin (version 9.0.0) to receive push notifications. Today I tried adding the Google maps plugin (version 9.8.0). As I suspected, this gave version conflicts in the google services plugin. I’m however not able to solve them. The message was:
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0..

So I downgraded the Google Maps plugin to 9.0.0. This didn’t work unfortunately, because some of the functions didn’t work anymore.

The next thought was upgrading the google services plugin. So I updated the SDK for google play, hoping it would fix things. I however can’t seem to use a higher version of google services, because I get this message when I build:
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.

Anybody know how to fix this? I have to use version 9.8.0 of google services, because otherwise the google maps plugin won’t work as expected…

config.xml

FCMPlugin.gradle

cordova-plugin-googlemaps plugin.xml

SDK tools

I think I managed to solve it. The FCM plugin uses the gradle file to apply the google-services plugin. What I did:

Comment out these lines in the FCMPlugin.gradle file.
classpath 'com.google.gms:google-services:3.0.0'
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Then change the plugin.xml of the FCM plugin to use a different version, in my situation 9.8.0.
<framework src="com.google.firebase:firebase-core:9.8.0" />
<framework src="com.google.firebase:firebase-messaging:9.8.0" />

Now, remove en add the android platform again, so the changes will have affect. The next step is to change the build.gradle file of the android platform folder.

Add this line to the classpath section
classpath 'com.google.gms:google-services:3.1.0'

And add this line below the dependencies, nearly at the bottom of the file
apply plugin: 'com.google.gms.google-services'

And these changes should fix the problems with the version conflicts.

15 Likes

I had exactly the same issue. Tried lots of things before reading your post. This was the only solution that helped. Thank you so much for sharing!!

1 Like

In my case, Its’ looks similar but I am unable to solve. Please help!

error :Execution failed for task ‘:processDebugGoogleServices’.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

1 Like

You’ve got exactly the same error as I had, so I don’t think the problem is different. Maybe you could provide more information than just the error? What have you tried to fix it? Which plugins do you have installed? Et cetera

Thanks for your reply! These are some details of my plugins and attempts :

Previously I was using Background Geolocation plugin (https://github.com/mauron85/cordova-plugin-background-geolocation) in my app and it was running fine.

Then I added the FCM (https://github.com/fechanique/cordova-plugin-fcm) plugin in the same app then I got this error.

I tried to change the version of com.google.android.gms to 9.0.0 in build gradle of android platform ( refer : https://github.com/fechanique/cordova-plugin-fcm/issues/274#issuecomment-307966519) and also tried your solution but not succeed yet. I also tried to change the gms version on Background Location plugin but it didn’t work.

But if I remove the Background Location plugin then my apps run successfully but I have to use both the plugins but their gms version are not matching. I observed (after going through the code of
plugins on github) that the gradle settings and structure of these plugin are little different.

Please inform if you need any more information about my attempts or plugins.

Thanks.

And when you changed the gms versions, or tried my solution, did you also remove and added the platform again?

yes, I removed and added android platform. Error with the gms of Background location is simailar :
Found com.google.android.gms:play-services-location:+, but version 9.0.0 is needed for the google-services plugin.

so I changed this in build file and project properties of android platform like ::

target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.firebase:firebase-core:9.0.0
cordova.system.library.2=com.google.firebase:firebase-messaging:9.0.0
cordova.gradle.include.1=cordova-plugin-fcm/businesskonnect-FCMPlugin.gradle
cordova.gradle.include.2=cordova-plugin-mauron85-background-geolocation/businesskonnect-logtofile.gradle
cordova.system.library.3=com.google.android.gms:play-services-location:9.0.0
cordova.system.library.4=com.android.support:support-v4:+

but now app crashes on Launch with following log ::
java.lang.IllegalAccessError: Method ‘void android.support.v4.content.ContextCompat.()’ is inaccessible to class ‘com.google.firebase.iid.zzg’ (declaration of ‘com.google.firebase.iid.zzg’.

At end its’ still not working.

I never said to change anything there. I suggest you read the solution again and try to follow these exact steps.

With exact steps, I end up with :
Found com.google.android.gms:play-services-location:+, but version 9.0.0 is needed for the google-services plugin

1 Like

It’s using the newest version of the plugin com.google.android.gms:play-services-location, hence the +. It needs version 9.0.0. So, try changing the + to 9.0.0.

As earlier stated ::
I changed this in build file and project properties of android platform like ::

target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.firebase:firebase-core:9.0.0
cordova.system.library.2=com.google.firebase:firebase-messaging:9.0.0
cordova.gradle.include.1=cordova-plugin-fcm/businesskonnect-FCMPlugin.gradle
cordova.gradle.include.2=cordova-plugin-mauron85-background-geolocation/businesskonnect-logtofile.gradle
cordova.system.library.3=com.google.android.gms:play-services-location:9.0.0
cordova.system.library.4=com.android.support:support-v4:+

but now app crashes on Launch with following log ::
java.lang.IllegalAccessError: Method ‘void android.support.v4.content.ContextCompat.()’ is inaccessible to class ‘com.google.firebase.iid.zzg’ (declaration of ‘com.google.firebase.iid.zzg’.

At end its’ still not working.

@abhishekdubey: I was experiencing the issue as well, when using the Native Maps-Plugin, the FCM-Plugin and the Background-Geolocation Plugin.

I was able to solve it, using @troovers guideline for FCM and Native Maps and adding one step (step 3) for the Background-Geolocation-Plugin.

What I did:

Step 1 (for FCM Plugin)
Comment out these lines in the FCMPlugin.gradle file.

classpath 'com.google.gms:google-services:3.0.0'
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Step 2 (for FCM Plugin)
Change the plugin.xml of the FCM plugin to use a different version, in my situation 9.8.0.

<framework src="com.google.firebase:firebase-core:9.8.0" />
<framework src="com.google.firebase:firebase-messaging:9.8.0" />

Step 3 (for Background-Geolocation-Plugin)
Change the plugin.xml of the Geolocation plugin to use a different version, in my situation 9.8.0 instead of “+”.

<framework src="com.google.android.gms:play-services-location:9.8.0" />

Step 4
Remove and re-add plattform.

Step 5 (build.gradle file of the android platform folder)
Add this line to the classpath section

classpath 'com.google.gms:google-services:3.1.0'

And add this line below the dependencies, nearly at the bottom of the file
apply plugin: 'com.google.gms.google-services'

5 Likes

I tried your solution but however it is not working. I got below error:

cordova build android
✖ Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

        (truncated) ... aseAssets
        :CordovaLib:mergeReleaseProguardFiles
        :CordovaLib:packageReleaseRenderscript UP-TO-DATE
        :CordovaLib:compileReleaseRenderscript
        :CordovaLib:generateReleaseResValues
        :CordovaLib:generateReleaseResources
        :CordovaLib:packageReleaseResources
        :CordovaLib:processReleaseManifest
        :CordovaLib:generateReleaseBuildConfig
        :CordovaLib:processReleaseResources
        :CordovaLib:generateReleaseSources
        :CordovaLib:incrementalReleaseJavaCompilationSafeguard
        :CordovaLib:compileReleaseJavaWithJavac
        :CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution,
        etc.).
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        :CordovaLib:processReleaseJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForRelease
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
        :CordovaLib:mergeReleaseJniLibFolders
        :CordovaLib:transformNative_libsWithMergeJniLibsForRelease
        :CordovaLib:transformNative_libsWithSyncJniLibsForRelease
        :CordovaLib:bundleRelease
        :prepareComAndroidSupportSupportCompat2600Alpha1Library
        :prepareComAndroidSupportSupportCoreUi2600Alpha1Library
        :prepareComAndroidSupportSupportCoreUtils2600Alpha1Library
        :prepareComAndroidSupportSupportFragment2600Alpha1Library
        :prepareComAndroidSupportSupportMediaCompat2600Alpha1Library
        :prepareComAndroidSupportSupportV42600Alpha1Library
        :prepareComGoogleAndroidGmsPlayServicesAds1102Library
        :prepareComGoogleAndroidGmsPlayServicesAdsLite1102Library
        :prepareComGoogleAndroidGmsPlayServicesBase1102Library
        :prepareComGoogleAndroidGmsPlayServicesBasement1102Library
        :prepareComGoogleAndroidGmsPlayServicesClearcut1102Library
        :prepareComGoogleAndroidGmsPlayServicesGass1102Library
        :prepareComGoogleAndroidGmsPlayServicesSafetynet1102Library
        :prepareComGoogleAndroidGmsPlayServicesTasks1102Library
        :prepareComGoogleFirebaseFirebaseAnalytics900Library
        :prepareComGoogleFirebaseFirebaseAnalyticsImpl900Library
        :prepareComGoogleFirebaseFirebaseCommon900Library
        :prepareComGoogleFirebaseFirebaseCore900Library
        :prepareComGoogleFirebaseFirebaseIid900Library
        :prepareComGoogleFirebaseFirebaseMessaging900Library
        :prepareDebugDependencies
        :compileDebugAidl
        :compileDebugRenderscript
        :generateDebugBuildConfig
        :generateDebugResValues
        :generateDebugResources
        :mergeDebugResources
        :processDebugManifest
        :processDebugResources
        :generateDebugSources
        :incrementalDebugJavaCompilationSafeguard
        :compileDebugJavaWithJavac
        :compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
        D:\Projects\Code\Other\DailySheet\DailySheetMobileApp\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseMessagingService.java:38:
        error: cannot access AbstractSafeParcelable
        if( remoteMessage.getNotification() != null){
        ^
        class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        Note:
        D:\Projects\Code\Other\DailySheet\DailySheetMobileApp\platforms\android\src\org\apache\cordova\file\AssetFilesystem.java
        uses unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.
        1 error

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':compileDebugJavaWithJavac'.
        > Compilation failed; see the compiler error output for details.

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

        BUILD FAILED

        Total time: 51.4 secs
        Error: cmd: Command failed with exit code 1 Error output:
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        D:\Projects\Code\Other\DailySheet\DailySheetMobileApp\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseMessagingService.java:38:
        error: cannot access AbstractSafeParcelable
        if( remoteMessage.getNotification() != null){
        ^
        class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        Note:
        D:\Projects\Code\Other\DailySheet\DailySheetMobileApp\platforms\android\src\org\apache\cordova\file\AssetFilesystem.java
        uses unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.
        1 error

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':compileDebugJavaWithJavac'.
        > Compilation failed; see the compiler error output for details.

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

I got build working.
Please do changes as mention in below solution.

but however when i run application in device, it stopped at launch time saying ‘Unfortunately, ***** has stopped’.

When i run my application, it stopped working.
What could be the reason?

Perhaps the power went out, you clicked the red button which closed it, the window is in the background, you got some errors in the console?

Maybe you should provide some more information…

I haven’t clicked any button, i just launched app and immediately it fails to start and displays message.
Also i checked for logs in console, but because application is not starting, i can’t track anything in chrome://inspect.

Did just like you said, worked great! Thanks man!

1 Like

i did the same but i also have this error :
Cannot add task ‘:processDebugGoogleServices’ as a task with that name already exists.
can you please help me
i’m using geolocation plugin and googlemaps plugin and fcm