1
votes

I'm trying to install Firebase in Ionic 4 app to use analytics and push notification for iOS and Android.

It seems to be impossible to build app on Android. I've already tried 3 different libs:

So the last one is my current attempt and its returning this errors

BUILD FAILED in 12s
3 actionable tasks: 3 executed
/Users/myuser/dev/myapp/myapp-ionic/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0.
  1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-stats:15.0.1 -> com.google.android.gms:play-services-basement@[
  15.0.1], but play-services-basement version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.firebase:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected].+
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected]

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency 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 b
  uild.gradle file.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 12s
[ERROR] An error occurred while running subprocess cordova.
        cordova build android exited with exit code 1.
        Re-running this command with the --verbose flag may provide more information.
-----------------------------------------------------

Am I doing something wrong? I'm so confused on how to implement Firebase in Ionic.

Here is my package.json file for reference.

{
  "name": "myapp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~8.1.2",
    "@angular/core": "~8.1.2",
    "@angular/forms": "~8.1.2",
    "@angular/platform-browser": "~8.1.2",
    "@angular/platform-browser-dynamic": "~8.1.2",
    "@angular/router": "~8.1.2",
    "@ionic-native/app-version": "^5.17.1",
    "@ionic-native/badge": "^5.17.1",
    "@ionic-native/barcode-scanner": "^5.17.1",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.17.1",
    "@ionic-native/diagnostic": "^5.17.1",
    "@ionic-native/firebase-analytics": "^5.17.1",
    "@ionic-native/geolocation": "^5.17.1",
    "@ionic-native/google-maps": "^5.0.0-beta.27",
    "@ionic-native/keyboard": "^5.17.1",
    "@ionic-native/network": "^5.17.1",
    "@ionic-native/screen-orientation": "^5.17.1",
    "@ionic-native/splash-screen": "^5.17.1",
    "@ionic-native/status-bar": "^5.17.1",
    "@ionic-native/vibration": "^5.17.1",
    "@ionic/angular": "^4.7.1",
    "@ionic/storage": "^2.2.0",
    "cordova-android": "8.1.0",
    "cordova-browser": "^6.0.0",
    "cordova-ios": "5.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-firebase-analytics": "^4.0.0",
    "cordova-plugin-firebase-lib": "^5.1.1",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
    "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-vibration": "^3.1.1",
    "cordova-support-android-plugin": "^1.0.1",
    "cordova-support-google-services": "^1.3.2",
    "cordova.plugins.diagnostic": "^5.0.1",
    "core-js": "^2.5.4",
    "es6-promise-plugin": "^4.2.2",
    "firebase": "^7.6.1",
    "ionicons": "git://github.com/ionic-team/ionicons.git#3.0",
    "ios-sim": "^8.0.2",
    "phonegap-plugin-barcodescanner": "^8.1.0",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1",
    "cordova-plugin-whitelist": "~1.3.3",
    "cordova-plugin-ionic-webview": "^4.0.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-statusbar": "~2.4.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "phonegap-plugin-push": "^2.3.0"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "~0.801.2",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.1.3",
    "cordova-plugin-splashscreen": "^5.0.3",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-whitelist": "^1.3.4",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-googlemaps": {
        "LOCATION_WHEN_IN_USE_DESCRIPTION": "This app wants to get your location while this app runs only.",
        "LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even this app runs in background."
      },
      "cordova-plugin-firebase-analytics": {
        "FIREBASE_ANALYTICS_VERSION": "17.2.+"
      },
      "cordova-plugin-app-version": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-screen-orientation": {},
      "cordova-plugin-vibration": {},
      "cordova-plugin-geolocation": {},
      "cordova.plugins.diagnostic": {
        "ANDROID_SUPPORT_VERSION": "28.+"
      },
      "cordova-plugin-badge": {},
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "phonegap-plugin-push": {
        "ANDROID_SUPPORT_V13_VERSION": "27.+",
        "FCM_VERSION": "17.0.+"
      },
      "cordova-plugin-firebase-lib": {}
    },
    "platforms": [
      "browser",
      "android",
      "ios"
    ]
  }
}
1
Add ur build.gradlePeter Haddad
@PeterHaddad I'm newbie to mobile apps. can you better explain?anderlaini

1 Answers

1
votes

Your problems in building Ionic with Firebase are common from what I've experienced as well as read on GitHub issues. The library versions can cause some difficulties and I had to play around with them for a while to get mine to work. Not all libraries are the latest. I recently built one with Firebase as well as Phonegap Plugin Push. I have not tried with Analytics yet though. Hope this helps.

Try adding "cordova-play-services-version-adapter": "git+https://github.com/appfeel/cordova-play-services-version-adapter.git",

Here is my latest working package.json that builds for Android.

{
    ...
    basic info here
    ...

    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "postinstall": "node version.js"
    },
    "private": true,
    "dependencies": {
        "@angular/common": "~8.2.13",
        "@angular/compiler": "~8.2.13",
        "@angular/core": "~8.2.13",
        "@angular/fire": "^5.2.3",
        "@angular/forms": "~8.2.13",
        "@angular/platform-browser": "~8.2.13",
        "@angular/platform-browser-dynamic": "~8.2.13",
        "@angular/router": "~8.2.13",
        "@ionic-native/admob-free": "^5.13.0",
        "@ionic-native/core": "^5.0.0",
        "@ionic-native/email-composer": "^5.16.0",
        "@ionic-native/push": "^5.18.0",
        "@ionic-native/splash-screen": "^5.0.0",
        "@ionic-native/status-bar": "^5.0.0",
        "@ionic-native/toast": "^5.12.0",
        "@ionic/angular": "^4.7.1",
        "cordova-admob-sdk": "^0.24.1",
        "cordova-android": "^8.1.0",
        "cordova-play-services-version-adapter": "git+https://github.com/appfeel/cordova-play-services-version-adapter.git",
        "cordova-plugin-admob-free": "0.27.0",
        "cordova-plugin-email-composer": "^0.9.2",
        "cordova-plugin-inappbrowser": "^3.1.0",
        "cordova-plugin-x-toast": "^2.7.2",
        "cordova-promise-polyfill": "0.0.2",
        "cordova-support-google-services": "1.3.2",
        "core-js": "^2.5.4",
        "firebase": "^7.4.0",
        "phonegap-plugin-multidex": "^1.0.0",
        "phonegap-plugin-push": "^2.3.0",
        "rxjs": "~6.5.1",
        "tslib": "^1.9.0",
        "zone.js": "~0.9.1"
    },
    "devDependencies": {
        "@angular-devkit/architect": "~0.801.2",
        "@angular-devkit/build-angular": "~0.803.18",
        "@angular-devkit/core": "~8.1.2",
        "@angular-devkit/schematics": "~8.1.2",
        "@angular/cli": "~8.3.18",
        "@angular/compiler-cli": "~8.2.13",
        "@angular/language-service": "~8.2.13",
        "@ionic/angular-toolkit": "~2.0.0",
        "@types/jasmine": "~3.3.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.9.4",
        "codelyzer": "^5.0.0",
        "cordova-config": "^0.7.0",
        "cordova-plugin-device": "^2.0.2",
        "cordova-plugin-ionic-keyboard": "^2.2.0",
        "cordova-plugin-ionic-webview": "^4.1.2",
        "cordova-plugin-splashscreen": "^5.0.2",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "cordova-version": "^0.1.3",
        "fs-extra": "^8.1.0",
        "gulp": "3.9.1",
        "gulp-bump": "^3.1.0",
        "gulp-file": "^0.4.0",
        "jasmine-core": "~3.4.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.1.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.4.0",
        "protractor": "~5.4.0",
        "replace": "^0.3.0",
        "shelljs": "^0.3.0",
        "tar": ">=4.4.2",
        "ts-node": "~7.0.0",
        "tslint": "~5.15.0",
        "typescript": "~3.5.3"
    },
    "cordova": {
        "plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-ionic-webview": {
                "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
            },
            "cordova-plugin-ionic-keyboard": {},
            "cordova-plugin-x-toast": {},
            "cordova-play-services-version-adapter": {},
            "cordova-plugin-email-composer": {
                "ANDROID_SUPPORT_V4_VERSION": "27.+"
            },
            "cordova-support-google-services": {},
            "cordova-plugin-admob-free": {
                "ADMOB_APP_ID": "REDACTED"
            },
            "cordova-admob-sdk": {
                "PLAY_SERVICES_VERSION": "17.0.0"
            },
            "phonegap-plugin-push": {
                "ANDROID_SUPPORT_V13_VERSION": "27.+",
                "FCM_VERSION": "17.0.+"
            },
            "cordova-plugin-inappbrowser": {}
        },
        "platforms": [
            "android"
        ]
    }
}