Ionic cordova build error after install @ionic-native/firebase

I installed firebase in ionic application (https://ionicframework.com/docs/v3/native/firebase/)

After installation, I started to give an error

@ionic-native/firebase/ngx/index.d.ts, found version 4, expected 3

I downgrade version to 3.14.0 and after the app stops building (android version)

then i run

ionic cordova build android --prod --release

or

ionic cordova run android

these errors appear in the console

Configure project :app
WARNING: The onesignal-gradle-plugin MUST be before com.android.application!
   Please put onesignal-gradle-plugin first OR update to com.android.tools.build:gradle:3.0.0 or newer!
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

FAILURE: Build failed with an exception.

* Where:
Script 'app/platforms/android/cordova-support-google-services/app-build.gradle' line: 16

* What went wrong:
A problem occurred evaluating project ':app'.
 Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
   For input string: "+"

* 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 0s
Command finished with error code 1: app/platforms/android/gradlew cdvBuildDebug,-b,app/platforms/android/build.gradle
app/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script 'app/platforms/android/cordova-support-google-services/app-build.gradle' line: 16

* What went wrong:
A problem occurred evaluating project ':app'.
 Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
   For input string: "+"

* 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 0s
Error: app/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script 'app/platforms/android/cordova-support-google-services/app-build.gradle' line: 16

* What went wrong:
A problem occurred evaluating project ':app'.
 Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
    For input string: "+"

* 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 0s
    at ChildProcess.whenDone (app/node_modules/cordova-common/src/superspawn.js:125:23)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
[ERROR] An error occurred while running subprocess cordova.
        
        cordova run android --verbose exited with exit code 1.

my dependencies in package.json

  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "4.3.2",
    "@ionic-native/facebook": "^4.2.1",
    "@ionic-native/firebase": "3.14.0",
    "@ionic-native/firebase-analytics": "^4.5.3",
    "@ionic-native/in-app-browser": "^4.4.2",
    "@ionic-native/keyboard": "^4.5.2",
    "@ionic-native/onesignal": "^4.5.3",
    "@ionic-native/social-sharing": "^4.2.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "@types/route-parser": "^0.1.1",
    "cordova-android": "8.0.0",
    "cordova-browser": "5.0.3",
    "cordova-custom-config": "^5.1.0",
    "cordova-ios": "4.5.4",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-customurlscheme": "^4.4.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-facebook4": "^1.10.1",
    "cordova-plugin-firebase": "2.0.5",
    "cordova-plugin-firebase-analytics": "^0.12.1",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "^5.4.1",
    "cordova-support-google-services": "^1.0.0",
    "es6-promise-plugin": "^4.2.2",
    "font-awesome": "^4.7.0",
    "fractional": "^1.0.0",
    "humps": "^2.0.1",
    "ionic-angular": "3.7.1",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "lodash": "^4.17.5",
    "onesignal-cordova-plugin": "^2.4.1",
    "pluralize": "^7.0.0",
    "route-parser": "0.0.5",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.3",
    "typescript": "2.3.4"
  },
  "description": "Hybrid App",
  "config": {
    "ionic_copy": "./config/copy.config.js"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-x-socialsharing": {},
      "cordova-plugin-facebook4": {
        "APP_ID": "xxxxxxxxxxxx",
        "APP_NAME": "xxxxxxx"
      },
      "cordova-plugin-ionic-webview": {},
      "cordova-support-google-services": {},
      "cordova-plugin-firebase-analytics": {
        "FIREBASE_VERSION": "11.0.+"
      },
      "onesignal-cordova-plugin": {},
      "cordova-plugin-customurlscheme": {
        "URL_SCHEME": "xxxxxxx",
        "ANDROID_SCHEME": " ",
        "ANDROID_HOST": " ",
        "ANDROID_PATHPREFIX": "/"
      },
      "cordova-custom-config": {},
      "cordova-plugin-firebase": {}
    },
    "platforms": [
      "browser",
      "ios",
      "android"
    ]
  }

ionic info

Ionic:

   ionic (Ionic CLI)  : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.7.1
   @ionic/app-scripts : 3.2.3

Cordova:

   cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms     : android 8.0.0
   Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 13 other plugins)

app/platforms/android/cordova-support-google-services/app-build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

It wasn`t possible to find a solution, maybe someone has encountered this problem and will help to solve it.
Thank!

I’ve same problem, have you found a solution ?

what is the android platform version u using? if u are at ionic 3 then when installing the platform android use @7 and don’t install the latest one. try reinstalling the platform and as u said u downgraded to 3 then re add ur plugins for that version of ionic as ionic 3 dont require u to add /ngx after import. also check the goodle play service version. changing version of the framework will require you to change a lot of stuff when building. hope this helps