55

I have a problem on an ionic project that it started happening yesterday without modifying any dependency.

When I run ionic cordova run android I have this error:

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.

But I didn't installed any dependency in these days.

This is my cordova plugins list:

cordova-fabric-plugin 1.1.14-dev "cordova-fabric-plugin"
cordova-plugin-advanced-http 2.0.9 "Advanced HTTP plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-appminimize 1.0.1 "AppMinimize"
cordova-plugin-apprate 1.4.0 "AppRate"
cordova-plugin-appsee 2.6.0 "Appsee"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-facebook4 3.2.0 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-firebase 2.0.5 "Google Firebase Plugin"
cordova-plugin-freshchat 1.2.0 "Freshchat plugin for Phonegap"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-inapppurchase-fixed 1.1.0 "In App Purchase"
cordova-plugin-insomnia 4.3.0 "Insomnia (prevent screen sleep)"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-nativegeocoder 3.2.2 "NativeGeocoder"
cordova-plugin-nativestorage 2.3.2 "NativeStorage"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.4 "SocialSharing"
cordova-support-google-services 1.2.1 "cordova-support-google-services"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-deeplinks 1.0.19 "Ionic Deeplink Plugin"
nl.kingsquare.cordova.background-audio 1.0.1 "background-audio"
pushwoosh-cordova-plugin 7.13.0 "Pushwoosh"

I found these dependencies in my platforms/android/app/build.gradle (if it's good to know):

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.squareup.okhttp3:okhttp-urlconnection:3.10.0"
    compile "com.google.android.gms:play-services-tagmanager:+"
    compile "com.google.firebase:firebase-core:+"
    compile "com.google.firebase:firebase-messaging:+"
    compile "com.google.firebase:firebase-config:+"
    compile "com.google.firebase:firebase-perf:+"
    compile "com.android.support:support-v4:26.+"
    compile "com.android.support:support-v4:27.+"
    compile "com.android.support:appcompat-v7:27.+"
    compile "com.android.support:recyclerview-v7:27.+"
    compile "com.android.support:design:27.+"
    compile "com.android.support.constraint:constraint-layout:1.0.2"
    compile "com.github.bumptech.glide:glide:4.7.1"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60"
    compile "com.pushwoosh:pushwoosh:5.13.0"
    compile "com.pushwoosh:pushwoosh-amazon:5.13.0"
    compile "com.pushwoosh:pushwoosh-badge:5.13.0"
    compile "com.pushwoosh:pushwoosh-inbox:5.13.0"
    compile "com.pushwoosh:pushwoosh-inbox-ui:5.13.0"
    compile "com.facebook.android:facebook-android-sdk:4.38.1"
    compile "com.appsee:appsee-android:2.6.0"
    // SUB-PROJECT DEPENDENCIES END
}

I don't know where to search. I found a workaround that is disabling version check of GoogleServicesPlugin in the platforms/android/build.gradle making: com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true but it doesn't work for me.

Thanks in advance.

EDIT: It seems like i'm not the only one. Here.

Ivan Lencina
  • 1,777
  • 1
  • 11
  • 25

11 Answers11

53

No solutions posted here worked for me. A wonderful person opened a pull request in the cordova-firebase-plugin official repo and it works.

Steps I did:

1 - Remove cordova-firebase-plugin with ionic cordova plugin remove cordova-plugin-firebase

2 - Install: ionic cordova plugin add cordova-plugin-firebasex

3 - rm -rf node_modules/ plugins/ platforms/android package-lock.json

4 - ionic cordova platform add android && npm install

And now it's working.

Ivan Lencina
  • 1,777
  • 1
  • 11
  • 25
  • 1
    sir it got error after install above command :Error: Failed to fetch plugin https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue via registry. – Kapil soni May 08 '19 at 05:14
  • Does actually work for android. But i got an error when adding platform ios: Failed to install 'cordova-plugin-firebase': CordovaError: Using "requireCordovaModule" to load non-cordova module "xcode" is not supported. Instead, add this module to your dependencies and use regular "require" to load it. – zidanex May 17 '19 at 11:27
  • As of today (June 19) the owner of that PR has created his [own fork of the plugin](https://github.com/dpa99c/cordova-plugin-firebase) so the command to install it would be `ionic cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase` – sebaferreras Jun 19 '19 at 10:38
  • Superb it worked. Thanks a ton Man. God bless you :) – Anand_5050 Nov 26 '19 at 06:14
19

I found a solution for me in the forum mentioned in Yannic Hamann answer (Ionic Forum).

The comment from systems_qualigy here is about locking the versions in project.properties.

cordova.system.library.4=com.google.firebase:firebase-core:16.0.8 
cordova.system.library.5=com.google.firebase:firebase-messaging:17.5.0 
cordova.system.library.6=com.google.firebase:firebase-config:16.4.1 
cordova.system.library.7=com.google.firebase:firebase-perf:16.2.4

I need also to lock the version of

com.google.android.gms:play-services-tagmanager:16.0.8

I took the version from Martins answer and could succesfully rebuild my project.

Hank Lapidez
  • 1,639
  • 16
  • 18
  • it works thanks! the `project.properties` file can be found inside `platforms/android/` folder. – Juan José Ramírez May 07 '19 at 15:51
  • @HankLapidez : i got this error :> Could not find com.google.firebase:firebase-core:16.0.8 . Searched in the following locations: – Kapil soni May 08 '19 at 04:56
  • @Kapilsoni Try "com.google.firebase:firebase-core:16.0.9" or search for a version already in your gradle cache – Hank Lapidez May 08 '19 at 06:38
  • @HankLapidez:i got this error : error: cannot find symbol public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService { ^ – Kapil soni May 08 '19 at 09:37
  • @Kapilsoni the [FirebaseInstanceIdService](https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceIdService) had been deprecated... while it should still find that class. – Martin Zeitler May 09 '19 at 06:46
  • @MartinZeitler: means sir we have put above link code inside the AndroidManifest.xml i am right? – Kapil soni May 09 '19 at 07:08
  • @Kapilsoni these setting go into `platforms/android/project.properties`. – Martin Zeitler May 09 '19 at 07:17
  • Applying this changes to `platforms/android/project.properties` fixed the problem in my project, but what about the warning at the top of this file? `#Do not modify this file -- YOUR CHANGES WILL BE ERASED!` where are these values taken from and when will be overrided? – Andrea Gobetti May 22 '19 at 13:33
6

We are now maintaining a forked version which includes all the changes & fixes done by different authors (who have saved everyone from this Google's move).

https://github.com/wizpanda/cordova-plugin-firebase-lib#difference-from-the-fork-repository

So, now just remove the existing plugin with:

ionic cordova plugin remove cordova-plugin-firebase

And now, install new version with

ionic cordova plugin add cordova-plugin-firebase-lib --save

Cheers!

Shashank Agrawal
  • 21,660
  • 9
  • 71
  • 105
  • Hi , I am trying to install this but its stuck – Rich5757 May 17 '19 at 16:35
  • Can you mention your `cordova-cli`, `cordova-android` & `cordova-ios` version? – Shashank Agrawal May 17 '19 at 16:51
  • I am not sure its releted I am seeing this issue now "TypeError: Cannot read property 'getToken' of undefined, i am using ionic 1 – Rich5757 May 17 '19 at 17:24
  • @Rich5757 I am still on Ionic 1 as well....did you resolve this Firebase issue and the getToken issue. I think the getToken is related because my problems all started at the same time and we made no plugin/dependency changes (for almost 3 months now). So whatever google did to Firebase caused the getToken issue as well. – rolinger Jun 07 '19 at 12:45
  • @ShashankAgrawal - is this going to be a permanent fix for the future `cordova-plugin-firebase` or do I need to permanently append my upgrade scripts to use this new forked version of the plugin? – rolinger Jun 07 '19 at 12:47
  • It depends. We are trying to maintain the fork as long as fixes & improvements are being done. – Shashank Agrawal Jun 08 '19 at 06:04
4

The Problem was due to the recent updates in firebase where some methods are now deprecated, check out Android Firebase releases. To fix the problem use the following patch of cordova plugin :

cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue
Felipe Augusto
  • 5,811
  • 7
  • 29
  • 60
Kiblawi_Rabee
  • 174
  • 2
  • 4
3

do as it says and run ./gradlew :app:dependencies in the Andoird project directory.

support-v4 is even added three times:

compile "com.android.support:support-v4:24.1.1+"
compile "com.android.support:support-v4:26.+"
compile "com.android.support:support-v4:27.+"

alike this the Gradle project synchronizes:

implementation project(":CordovaLib")

implementation "com.google.android.gms:play-services-tagmanager:16.0.8"

implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation "com.google.firebase:firebase-config:17.0.0"
implementation "com.google.firebase:firebase-perf:17.0.0"
implementation "com.google.firebase:firebase-core:16.0.9"

implementation "com.android.support:design:28.0.0"
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:customtabs:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation "com.android.support:animated-vector-drawable:28.0.0"
implementation "com.android.support.constraint:constraint-layout:1.1.3"

implementation "com.facebook.android:facebook-android-sdk:4.42.0"
implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60"
implementation "com.github.bumptech.glide:glide:4.9.0"
implementation "com.appsee:appsee-android:2.6.0"

implementation "com.pushwoosh:pushwoosh:5.13.0"
implementation "com.pushwoosh:pushwoosh-amazon:5.13.0"
implementation "com.pushwoosh:pushwoosh-badge:5.13.0"
implementation "com.pushwoosh:pushwoosh-inbox:5.13.0"
implementation "com.pushwoosh:pushwoosh-inbox-ui:5.13.0"
Martin Zeitler
  • 49,224
  • 12
  • 97
  • 156
2

I am having exactly the same issue. The problem is caused by cordova-plugin-firebase. I am currently investigating. Will update this answer when I found the exact course.

For now you can try to ionic cordova plugin rm <plugin> to see whether this resolves your current error too.

Update: Have a look here for possible fixes. This open PR seems to work. Hopefully it will be merged very soon.

Yannic Hamann
  • 3,462
  • 23
  • 40
  • Yes, I thought the same as you. I think the problem is the firebase plugin. I could try but, we use it for a/b tests so, I should make it works soon. Let me know if you solve this :) – Ivan Lencina May 07 '19 at 04:26
  • Their travis tests are failing https://github.com/arnesson/cordova-plugin-firebase – Ivan Lencina May 07 '19 at 04:29
2

I just added below in project.properties which is under android platform dir and it got worked

cordova.system.library.4=com.google.firebase:firebase-core:16.0.8 
cordova.system.library.5=com.google.firebase:firebase-messaging:17.5.0 
cordova.system.library.6=com.google.firebase:firebase-config:16.4.1 
cordova.system.library.7=com.google.firebase:firebase-perf:16.2.4
1

I was facing the same error, I just deleted platforms/android and installed again (ionic cordova prepare android) then everything went back as it was.

Felipe Augusto
  • 5,811
  • 7
  • 29
  • 60
  • it seems to make sense, previous builds conflict with the current plugin and its dependencies (probably), doing from scratch it will have to generate correctly according to the installed plugins. I'll test, thank you very much for the tip. – Guilherme Nascimento Jun 13 '19 at 19:28
1

Ionic 4 : 20-05-2019

This works for me:

platforms/android/project.properties

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.squareup.okhttp3:okhttp-urlconnection:3.10.0
cordova.gradle.include.1=cordova-plugin-firebase/com1-build.gradle
cordova.system.library.2=com.google.android.gms:play-services-tagmanager:16.0.8
cordova.system.library.3=com.google.firebase:firebase-core:16.0.8
cordova.system.library.4=com.google.firebase:firebase-messaging:17.5.0
cordova.system.library.5=com.google.firebase:firebase-config:16.4.1
cordova.system.library.6=com.google.firebase:firebase-perf:16.2.4
cordova.system.library.7=com.android.support:support-annotations:27.+
Sampath
  • 50,641
  • 40
  • 250
  • 357
0

First, try to remove firebase using

ionic cordova plugin rm cordova-plugin-firebase

and install it again.

Raj Gohel
  • 635
  • 2
  • 11
0

Follow my perfect solution for the cordova firebase issue.

  1. ionic cordova platform rm android
  2. npm uninstall -g cordova
  3. npm install -g cordova@9.0.0
  4. ionic cordova platform add android (e.g v8.0.0)
  5. ionic cordova plugin add cordova-plugin-firebasex (e.g v6.0.7)
  6. ionic cordova run android

New cordova-plugin-firebasex plugin will fix all the issues related to firebase and it is really good alternative for cordova-plugin-firebase.

Manoj Alwis
  • 833
  • 7
  • 18