Firebase Cordova Plugin not working

HI Everyone,

I was using Cordova Plugin Firebase package for push notifications and it works pretty well.

But today got the error while building the build for Android.

This is the error message I got when running the project

The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.5.0,16.5.0], [16.4.0,16.4.0]], but resolves to 16.5.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Also, On Github this is an open issue. Although, few of the users commenting that they have succesfully counter the issue but their solution not working for me.

Also, Can anyone tell me how to create a project.properties files while building the app for Cordova? I am asking this because some of the users mention adding the project.properties file in their project solves the issue.

Add cordova-play-services-version-adapter plugin…I think it tries to resolve the play services versions requested by various plugins. It solves my firebase problem.

Are you using the same version cordova firebase plugin 2.0.5 or any other plugin?

Can you please check and revert which plugin are you using right now!

I do not use the cordova firebase plugin directly. It is used by raix:push package. It is npm firebase-admin 7.0.0.
Hope this helps

Okay, let me check for this!
Thanks

@perumalkuk, I checked that but its not working

I got this error before starting the App and then the same error

‘Cordova Play Services Version Adapter’ has detected an error. The following dependencies of ‘Google Play Services’ are not compatible:
You have an incompatibility of versions with the following dependencies of ‘Google Play Services’:
- ‘com.google.android.gms:play-services-auth:11.8.0’
- ‘com.google.android.gms:play-services-identity:11.8.0’
- ‘com.google.android.gms:play-services-tagmanager:+’
- ‘com.google.firebase:firebase-core:+’
- ‘com.google.firebase:firebase-messaging:+’
- ‘com.google.firebase:firebase-config:+’
- ‘com.google.firebase:firebase-perf:+’

It doesn’t exists a version of ‘Google Play Services’ that includes all these dependencies.
All dependencies of ‘Google Play Services’ must have the same version.
The application may not compile.

BUILD FAILED in 2m 17s
{ Error: /usr/Data/Meteor/sn_aws-web/.meteor/local/cordova-build/platforms/android/gradlew: 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.

FAILURE: Build failed with an exception.

  • What went wrong:
    The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.5.0,16.5.0], [16.4.0,16.4.0]], but resolves to 16.5.0. Disable the plugin and check your
    dependencies tree using ./gradlew :app:dependencies.

It does not work, can you please check whats the issue?

You may have to use adapters similar to one I have mentioned(check cordova-android-support-gradle-release or cordova-android-firebase-gradle-release - check their documentation), that helps sort the problem. it is trial and error and choosing the right version of plugin so that dependencies match

Hi,
in your Android project you need to add all those latest versions for Firebase messaging and the rest of the Android plugins in android/app/ build.gradle. For Firebase Messaging you might end up with 11… instead of 17. while the latests is 18 I believe.
In this Meteor Push package https://github.com/activitree/meteor-push I use cordova-android-support-gradle-release@1.4.5 to overcome this error you have now. However the latested version of this plugin is now 3+.

Solution Worked for Me, Go to .meteor/local/cordova-build/platforms/android/project.properties
and changing the following (in Bold)

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.2=com.google.android.gms:play-services-identity:11.8.0
cordova.gradle.include.1=cordova-plugin-meteor-webapp/specialn-build-extras.gradle
cordova.system.library.3=com.squareup.okhttp3:okhttp:3.9.1
cordova.system.library.4=com.facebook.android:facebook-android-sdk:4.38.1
cordova.gradle.include.2=cordova-plugin-firebase/specialn-build.gradle
cordova.system.library.5=com.google.android.gms:play-services-tagmanager:16+
cordova.system.library.6=com.google.firebase:firebase-core:16.0.8
cordova.system.library.7=com.google.firebase:firebase-messaging:17.5.0
cordova.system.library.8=com.google.firebase:firebase-config:16.4.1
cordova.system.library.9=com.google.firebase:firebase-perf:16.2.4
cordova.gradle.include.3=cordova-android-support-gradle-release/specialn-cordova-android-support-gradle-release.gradle

Thanks @paulishca, I found the solution of the problem.

I will try using this plugin you suggested.

Thanks @perumalkuk, Found the solution!!

Great. But if it is editing project.properties …then it may not be the right solution. I would suggest exploring the right way of using cordova-android-support-gradle-release or the other as suggested above by passing the right parameters using mobile-config.js file using custom config plugin to the cordova plugins

I’m having this same problem now with cordova-plugin-firebase (actually I was using this fork but I’ve tried the original again and have the same problem)

The library com.google.firebase:firebase-iid is being requested by various other libraries at [[17.1.1,17.1.1]], but resolves to 19.0.0

@mixmatric, what solution worked for you in the end? Does it still work? What versions of the various packages are you using?

I’ve tried cordova:cordova-android-support-gradle-release@1.4.5 but get the error

cordova-android-support-gradle-release: Android platform: cordova-android@7
cordova-android-support-gradle-release: ERROR: EXCEPTION: TypeError: Cannot read property ‘length’ of undefined

I tried cordova-android-support-gradle-release@3.0.1 but get the error:

cordova-android-support-gradle-release: Unable to load node module dependency ‘q’: Cannot find module 'q’

I’ve tried editing the project.properties file with the version number above but still get lots of errors

@perumalkuk, how am I supposed to find the correct version of cordova-android-support-gradle-relese? Or what versions number am I support to pass in mobile-config, and how? I’ve done that previously in other apps, e.g.

  <plugin name="cordova-plugin-mauron85-background-geolocation" spec="^3.0.0-alpha.50">
    <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="15+" />
    <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
  </plugin>

But what values should be used for cordova-plugin-firebase?

This is extremely frustrating. I used to be able to build android apps easily but now I’m stuck not being able to update my app at all! And I’ve recommended meteor here on the forums as an easy way to develop apps. There are other forks of cordova-plugin-firebase and other similar packages but many of them require more recent versions for cordova or have these same issues.

Just attaching my cordova plugins list Hopefully it will give some hint.

`>

cordova-custom-config@5.1.0
cordova-play-services-version-adapter@1.0.2
cordova-plugin-android-permissions@1.0.0
cordova-plugin-appinfo@2.1.2
cordova-plugin-calendar@5.1.4
cordova-plugin-camera@4.0.3
cordova-plugin-device@2.0.2
cordova-plugin-file@6.0.1
cordova-plugin-file-transfer@1.7.1
cordova-plugin-geolocation@4.0.1
cordova-plugin-inappbrowser@3.0.0
cordova-plugin-media-capture@3.0.2
cordova-plugin-meteor-webapp@1.7.0
cordova-plugin-network-information@2.0.1
cordova-plugin-splashscreen@5.0.2
cordova-support-google-services@1.3.1
phonegap-nfc-isodep@https://github.com/as-eldlc/phonegap-nfc-isodep.git#d34fc1943832c620aa1e1358211069128a587fd7
phonegap-plugin-push@2.2.3
``

For me the cordova-play-services-version-adapter does the trick. I do not touch properties files or do any change for gradle

1 Like

Thank @perumalkuk, looks like that is working. I had to replace cordova-firebase-plugin with phonegap-plugin-push@2.2.3 which will mean re-writing some of my client code, but so far it seems to work (builds app, registers gcm token, next I’ll try receiving a push message…)

This worked for me, I had to change the project.properties files to make this works!

Hi did try that, with various versions of cordova-firebase-plugin but kept getting various errors.

I’m up and running now with cordova-play-services-version-adapter and phonegap-plugin-push

Thanks everyone.

@mixmatric, I’m not finding phonegap-plugin-push as easy to use with iOS, so I’d like to try cordova-firebase-plugin again which was working perfectly for me previously. Can you post your .meteor/cordova-plugins file so I can see exactly which versions of plugins you got it working with?

I thought let me jump in …I actually use raix:push which uses phonegap-plugin-push, but found that it was not possible to use p8 so ended using apn for ios messages and continue to use raix:push for android

cordova-plugin-device@2.0.2
com.telerik.plugins.nativepagetransitions@0.6.5
cordova-plugin-facebook4@4.1.0
cordova-plugin-file-transfer@1.7.1
cordova-plugin-googleplus@7.0.0
cordova-plugin-progressdialog@2.0.2
cordova-plugin-x-toast@2.7.2
cordova-plugin-progressindicator@1.2.0
cordova-plugin-inappbrowser@3.0.0
cordova-plugin-firebase@2.0.5

This is my file @wildhart