After installing google maps plugin "object(....) is not a function"

#1

hi
I was trying to add google maps to an app that I was working on and after running these commands :

ionic cordova plugin add cordova-plugin-googlemaps \
  --variable API_KEY_FOR_ANDROID="key" \
  --variable API_KEY_FOR_IOS="key"
npm install @ionic-native/core @ionic-native/google-maps

I get this error:

 Runtime error
    Object(...) is not a function

even though I didn’t use the plugin in my code yet !

here is my package.json :

{
  "name": "cake-driver",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/base64": "^4.20.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/google-maps": "^4.20.0",
    "@ionic-native/image-picker": "^4.20.0",
    "@ionic-native/onesignal": "^4.20.0",
    "@ionic-native/splash-screen": "~4.18.0",
    "@ionic-native/status-bar": "~4.18.0",
    "@ionic/pro": "2.0.4",
    "@ionic/storage": "^2.2.0",
    "com-badrit-base64": "0.2.0",
    "cordova-android": "7.1.4",
    "cordova-ios": "4.5.5",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-googlemaps": "2.5.0",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^2.3.3",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-telerik-imagepicker": "2.2.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "3.0.0",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "onesignal-cordova-plugin": "2.4.6",
    "rxjs": "6.0.0",
    "rxjs-compat": "^6.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.1",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "onesignal-cordova-plugin": {},
      "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-telerik-imagepicker": {
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "yoWe need this permission to get the needed photos"
      },
      "com-badrit-base64": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "AIzaSyCOd-Z643z1lP19CDHw-tr3eBugmpAXz8k",
        "API_KEY_FOR_IOS": "AIzaSyDFr-FqOKG_WDNKYggLeCJw8yPPkHOyR5Q"
      }
    },
    "platforms": [
      "android"
    ]
  }
}
#2

I have found the issue, google maps needs some dependencies which were not included in the installing steps in their docs, after I installed those dependancies it worked fine

#3

good morning, sorry for the dependencies you installed, I’m having the same problem and then everything I found is the first post that touches what is happening to me

#4

try running npm install and you should see some warnings for the missing dependancies, just install them, if you still facing the same problem after that just try to remove and add the platforms again.