Can't build after installing @ionic-native/firebase-analytics

I’m using Ionic 4 and I would like to use what is described in https://ionicframework.com/docs/native/firebase-analytics but after installing the dependencies I can’t build the app, it fails with

ERROR: In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[18.0.0]", 
but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.google.firebase:firebase-messaging:18.0.0 -> com.google.firebase:firebase-iid@[18.0.0], but firebase-iid version was 19.0.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the artifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-iid@{strictly 19.0.0}
-- Project 'app' depends onto com.microsoft.appcenter:appcenter-push@{strictly 2.4.1}
-- Project 'app' depends onto com.microsoft.appcenter:appcenter-push@2.4.1
-- Project 'app' depends onto com.google.firebase:firebase-messaging@{strictly 18.0.0}
-- Project 'app' depends onto com.google.firebase:firebase-analytics@{strictly 17.2.1}
-- Project 'app' depends onto com.google.firebase:firebase-core@{strictly 16.0.9}
-- Project 'app' depends onto com.google.firebase:firebase-analytics@17.2.+
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@{strictly 17.2.1}

For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dependency 
paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://github.com/google/play-services-plugins 
and disable by adding "googleServices { disableVersionCheck = false }" to your build.gradle file.

As suggested in the error above I’ve runned ./gradlew --info :app:assembleDebug and it shows me

Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase, artifactId=firebase-messaging, version=18.0.0), toArtifact=Artifact(groupId=com.google.firebase, artifactId=firebase-iid), toArtifactVersionString=[18.0.0])
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)
NOTE: com.google.android.gms translated to c.g.a.g for brevity. Same for com.google.firebase -> c.g.f
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> com.microsoft.appcenter:appcenter-push@2.4.1
---- com.microsoft.appcenter:appcenter-push:2.4.1 library depends -> c.g.f:firebase-core@16.0.9
------ c.g.f:firebase-core:16.0.9 library depends -> c.g.f:firebase-analytics@16.5.0
-------- c.g.f:firebase-analytics:17.2.1 library depends -> c.g.a.g:play-services-measurement-api@17.2.1
---------- c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> com.microsoft.appcenter:appcenter-push@{strictly 2.4.1}
---- com.microsoft.appcenter:appcenter-push:2.4.1 library depends -> c.g.f:firebase-core@16.0.9
------ c.g.f:firebase-core:16.0.9 library depends -> c.g.f:firebase-analytics@16.5.0
-------- c.g.f:firebase-analytics:17.2.1 library depends -> c.g.a.g:play-services-measurement-api@17.2.1
---------- c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.f:firebase-core@{strictly 16.0.9}
---- c.g.f:firebase-core:16.0.9 library depends -> c.g.f:firebase-analytics@16.5.0
------ c.g.f:firebase-analytics:17.2.1 library depends -> c.g.a.g:play-services-measurement-api@17.2.1
-------- c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.f:firebase-analytics@17.2.+
---- c.g.f:firebase-analytics:17.2.1 library depends -> c.g.a.g:play-services-measurement-api@17.2.1
------ c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.f:firebase-analytics@{strictly 17.2.1}
---- c.g.f:firebase-analytics:17.2.1 library depends -> c.g.a.g:play-services-measurement-api@17.2.1
------ c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.a.g:play-services-measurement-api@{strictly 17.2.1}
---- c.g.a.g:play-services-measurement-api:17.2.1 library depends -> c.g.f:firebase-iid@19.0.0
-- :app-debugCompileClasspath-capacitor-android:0.0.0 task/module dep -> c.g.f:firebase-iid@{strictly 18.0.0}
-- :app-debugCompileClasspath-capacitor-android:0.0.0 task/module dep -> c.g.f:firebase-messaging@18.0.0
---- c.g.f:firebase-messaging:18.0.0 library depends -> c.g.f:firebase-iid@[18.0.0]
-- :app-debugCompileClasspath-capacitor-android:0.0.0 task/module dep -> c.g.f:firebase-messaging@{strictly 18.0.0}
---- c.g.f:firebase-messaging:18.0.0 library depends -> c.g.f:firebase-iid@[18.0.0]
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> com.microsoft.appcenter:appcenter-push@2.4.1
---- com.microsoft.appcenter:appcenter-push:2.4.1 library depends -> c.g.f:firebase-messaging@18.0.0
------ c.g.f:firebase-messaging:18.0.0 library depends -> c.g.f:firebase-iid@[18.0.0]
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> com.microsoft.appcenter:appcenter-push@{strictly 2.4.1}
---- com.microsoft.appcenter:appcenter-push:2.4.1 library depends -> c.g.f:firebase-messaging@18.0.0
------ c.g.f:firebase-messaging:18.0.0 library depends -> c.g.f:firebase-iid@[18.0.0]
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.f:firebase-messaging@{strictly 18.0.0}
---- c.g.f:firebase-messaging:18.0.0 library depends -> c.g.f:firebase-iid@[18.0.0]
-- :app-debugCompileClasspath-capacitor-cordova-android-plugins:0.0.0 task/module dep -> c.g.f:firebase-iid@{strictly 19.0.0}
Task :capacitor-cordova-android-plugins:javaPreCompileDebug in app Finished
:capacitor-cordova-android-plugins:javaPreCompileDebug (Thread[Execution worker for ':' Thread 3,5,main]) completed. Took 12.307 secs.

I can see why the conflict with the versions but I don’t know how to solve it and it seems imposible for me.

Here is my dependencies in package.json in case it helps to figure out a solution.

"dependencies": {
    "@angular/animations": "~8.2.11",
    "@angular/common": "~8.2.11",
    "@angular/compiler": "~8.2.11",
    "@angular/core": "~8.2.11",
    "@angular/forms": "~8.2.11",
    "@angular/platform-browser": "~8.2.11",
    "@angular/platform-browser-dynamic": "~8.2.11",
    "@angular/router": "~8.2.11",
    "@aspnet/signalr": "^1.1.4",
    "@capacitor/android": "1.2.1",
    "@capacitor/core": "1.2.1",
    "@capacitor/ios": "1.2.1",
    "@ionic-native/app-center-analytics": "^5.19.1",
    "@ionic-native/app-center-crashes": "^5.19.1",
    "@ionic-native/app-center-push": "^5.19.1",
    "@ionic-native/core": "^5.14.0",
    "@ionic-native/firebase-analytics": "^5.19.1",
    "@ionic-native/market": "^5.15.0",
    "@ionic-native/social-sharing": "^5.15.0",
    "@ionic/angular": "^4.10.3",
    "@ionic/pwa-elements": "^1.4.1",
    "@ionic/storage": "^2.2.0",
    "@ngrx/effects": "^8.4.0",
    "@ngrx/entity": "^8.4.0",
    "@ngrx/router-store": "^8.4.0",
    "@ngrx/store": "^8.4.0",
    "@ngrx/store-devtools": "^8.4.0",
    "chart.js": "^2.8.0",
    "chartjs-plugin-annotation": "^0.5.7",
    "cordova-plugin-advanced-http": "^2.1.1",
    "cordova-plugin-appcenter-analytics": "^0.5.1",
    "cordova-plugin-appcenter-crashes": "^0.5.1",
    "cordova-plugin-appcenter-push": "^0.5.1",
    "cordova-plugin-appcenter-shared": "^0.5.1",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-firebase-analytics": "4.0.1",
    "cordova-plugin-market": "^1.2.0",
    "cordova-plugin-x-socialsharing": "^5.6.0",
    "cordova-sqlite-storage": "^3.3.0",
    "cordova-support-android-plugin": "^1.0.1",
    "cordova-support-google-services": "^1.3.2",
    "core-js": "^2.5.4",
    "es6-promise-plugin": "^4.2.2",
    "ionic-appauth": "^0.4.1",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "ng2-charts": "^2.2.4",
    "object-path": "^0.11.4",
    "rxjs": "^6.5.3",
    "tslib": "^1.9.0",
    "xml2js": "^0.4.22",
    "zone.js": "~0.9.1"
  },

Any ideas?

I also faced such type of issues … Try installing these two plugins which provides dependencies for android 10…
cordova-plugin-androidx
cordova-plugin-androidx-adapter…

Another thing which i think creating conflict is that you are using two analytics.
appcenter-analytics and firebaseanayltics…

Changing the version to ‘+’ of the firebaseplugin in the project properties in platform->Android folder…

Do let me know if this works out…

Hey, @ketanambekar, thanks for your reply.
Sadly, it didn’t work for me. cordova-plugin-androidx and cordova-plugin-androidx-adapter does not work with capacitor. I ended up manually specifying
implementation 'com.google.firebase:firebase-analytics:16.0.6'
in my android\app\build.gradle and using this plugin https://github.com/stewwan/capacitor-analytics

It is working, I’m ok with that. I wish I could use the Ionic native plugin with the latest version of firebase-analytics

2 Likes

oh ok ok, I thought you were using cordova in your app… Yes I think for now we need to add manually only in capacitor…