Cordova Build Error: Metadata Version Mismatch

Hello guys, everytime I run ionic cordova build android --release --prod, I get the following error:

Error: Metadata version mismatch for module
C:/Users/Kenny/Projects/CBSTC/User/node_modules/@ionic-native/google-maps/index.d.ts, found version 4, expected 3

Anyone else experienced it before? Thanks in advance…

Here’s my ionic info by the way:

[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.

Ionic:

   ionic (Ionic CLI)  : 4.10.2 (C:\Users\Kenny\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.3
   @ionic/app-scripts : 2.1.4

Cordova:

   cordova (Cordova CLI) : 6.5.0
   Cordova Platforms     : android 6.1.2
   Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 21 other plugins)

System:

   NodeJS : v10.15.1 (C:\Program Files\nodejs\node.exe)
   npm    : 2.15.12
   OS     : Windows 10

and my package.json dependencies:

"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/background-mode": "^4.9.1",
    "@ionic-native/browser-tab": "^4.9.1",
    "@ionic-native/call-number": "^4.9.1",
    "@ionic-native/camera": "^3.14.0",
    "@ionic-native/core": "^3.14.0",
    "@ionic-native/diagnostic": "^3.14.0",
    "@ionic-native/firebase": "^4.9.1",
    "@ionic-native/google-maps": "^4.2.1",
    "@ionic-native/http": "^3.14.0",
    "@ionic-native/in-app-browser": "^4.9.1",
    "@ionic-native/location-accuracy": "^3.14.0",
    "@ionic-native/onesignal": "^4.9.1",
    "@ionic-native/paypal": "^4.9.1",
    "@ionic-native/social-sharing": "^4.9.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic-native/stripe": "^4.9.1",
    "@ionic-native/vibration": "^4.9.1",
    "@ionic/storage": "2.0.1",
    "angular": "^1.7.2",
    "body-parser": "^1.18.3",
    "browser-sync": "^2.24.7",
    "call-number": "git+https://github.com/Rohfosho/CordovaCallNumberPlugin.git",
    "cheerio": "^0.19.0",
    "cordova-browser": "^5.0.4",
    "cordova-custom-config": "git+https://github.com/dpa99c/cordova-custom-config.git",
    "cordova-ios": "4.5.4",
    "cordova-plugin-accountkit": "^1.4.0",
    "cordova-plugin-advanced-http": "^2.0.1",
    "cordova-plugin-background-mode": "^0.7.2",
    "cordova-plugin-browsertab": "^0.2.0",
    "cordova-plugin-buildinfo": "^1.1.0",
    "cordova-plugin-camera": "^3.0.0",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-googlemaps": "^2.4.4",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-ionic-wkkeyboard": "^1.1.15",
    "cordova-plugin-paystack": "git+https://github.com/blinks32/cordova-paystack-plugin-updated.git",
    "cordova-plugin-request-location-accuracy": "^2.2.3",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-vibration": "^2.1.6",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "^5.4.1",
    "cordova.plugins.diagnostic": "^4.0.10",
    "cors": "^2.8.4",
    "csp-parse": "0.0.2",
    "elementtree": "^0.1.7",
    "es6-promise-plugin": "^4.2.2",
    "express": "^4.16.3",
    "glob": "^5.0.15",
    "ionic-angular": "^3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic2-rating": "^1.2.2",
    "ionicons": "3.0.0",
    "make-dir": "^1.3.0",
    "minimist": "^1.2.0",
    "mx.ferreyra.callnumber": "0.0.2",
    "npm": "^2.15.12",
    "onesignal-cordova-plugin": "^2.4.4",
    "plist": "^1.2.0",
    "promise-polyfill": "6.0.2",
    "q": "^1.5.1",
    "rxjs": "5.4.0",
    "stripe": "^5.10.0",
    "sw-toolbox": "3.6.0",
    "xml2js": "^0.4.19",
    "zone.js": "0.8.12"
  },

Update Your package.json Dependencies.
Then remove node folder and install again with update dependencies.

Thanks for the response… what particular dependencies should I update and to what version? The @ionic-native/* ones?

Can you do a normal ionic build --prod with that project? This doesn’t look at all like a Cordova problem.

That being said:

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

Hi @Sujan12, same results using ionic build --prod.

$ ionic build --prod
[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.
> ionic-app-scripts build --prod
[16:38:11]  ionic-app-scripts 2.1.4
[16:38:11]  build prod started ...
[16:38:11]  clean started ...
[16:38:11]  clean finished in 60 ms
[16:38:11]  copy started ...
[16:38:11]  ngc started ...
[16:38:28]  ionic-app-script task: "build"
[16:38:28]  Error: Metadata version mismatch for module
            C:/Users/Kenny/Projects/CBSTC/User/node_modules/@ionic-native/onesignal/index.d.ts, found version 4,
            expected 3
Error: Metadata version mismatch for module C:/Users/Kenny/Projects/CBSTC/User/node_modules/@ionic-native/onesignal/index.d.ts, found version 4, expected 3
    at StaticSymbolResolver.getModuleMetadata (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:24474:34)
    at StaticSymbolResolver._createSymbolsOf (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:24260:46)
    at StaticSymbolResolver.getSymbolsOf (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:24241:14)
    at C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:23023:30
    at Array.forEach (<anonymous>)
    at extractProgramSymbols (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:23022:79)
    at AotCompiler.compileAll (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler\bundles\compiler.umd.js:22720:47)
    at CodeGenerator.codegen (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler-cli\src\codegen.js:30:14)
    at Function.NgTools_InternalApi_NG_2.codeGen (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@angular\compiler-cli\src\ngtools_api.js:61:30)
    at Object.doCodegen (C:\Users\Kenny\Projects\CBSTC\User\node_modules\@ionic\app-scripts\dist\aot\codegen.js:6:51)
[ERROR] An error occurred while running subprocess ionic-app-scripts.

        ionic-app-scripts build --prod exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

Also, what cordova version would you recommend that I change it to?

Thank you very much.

Which means your error has nothing to do with Cordova, your Ionic project is just broken right now. Fix this, then you will also be able to build with Cordova.

Read the linked article, it explains everything. (Although this is not related to the problem you are having here right now.)

Thanks @Sujan12, I managed to make it work by updating the package.json file using https://update.ionic.zone/ and changing the @ionic-native/google-maps to ^4.9.1 afterwards.

3 Likes

Am having same issue please help:

{
“name”: “mobile”,
“version”: “1.0.1”,
“author”: “e-pplication”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
@angular/animations”: “4.1.3”,
@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.4.7”,
@angular/platform-browser”: “4.1.3”,
@angular/platform-browser-dynamic”: “4.1.3”,
@ionic-native/app-update”: “^4.20.0”,
@ionic-native/camera”: “^4.20.0”,
@ionic-native/core”: “4.3.3”,
@ionic-native/file”: “^4.20.0”,
@ionic-native/file-transfer”: “^4.20.0”,
@ionic-native/speech-recognition”: “^4.20.0”,
@ionic-native/splash-screen”: “3.12.1”,
@ionic-native/status-bar”: “3.12.1”,
@ionic/storage”: “2.0.1”,
@ng-idle/core”: “^8.0.0-beta.4”,
@ng-idle/keepalive”: “^8.0.0-beta.4”,
“angular-common”: “^0.1.0”,
“angular2-text-mask”: “^9.0.0”,
“cordova-android”: “^6.2.3”,
“cordova-ios”: “^5.0.1”,
“cordova-plugin-camera”: “^4.1.0”,
“cordova-plugin-console”: “^1.0.5”,
“cordova-plugin-device”: “^1.1.4”,
“cordova-plugin-file”: “^6.0.2”,
“cordova-plugin-file-transfer”: “^1.7.1”,
“cordova-plugin-speechrecognition”: “^1.1.2”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-statusbar”: “^2.4.3”,
“cordova-plugin-whitelist”: “^1.3.4”,
“google-libphonenumber”: “^3.2.3”,
“ionic-angular”: “3.6.1”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“rxjs”: “5.4.0”,
“sw-toolbox”: “3.6.0”,
“text-mask-addons”: “^3.8.0”,
“text-mask-core”: “^5.1.2”,
“zone.js”: “0.8.12”
},
“devDependencies”: {
@ionic/app-scripts”: “^3.2.4”,
@ionic/lab”: “1.0.8”,
“cordova-plugin-ionic-keyboard”: “^2.1.3”,
“cordova-plugin-ionic-webview”: “^2.5.1”,
“mocha”: “^5.2.0”,
“typescript”: “2.3.4”
},
“description”: “e-Application”,
“cordova”: {
“plugins”: {
“cordova-plugin-speechrecognition”: {},
“cordova-plugin-console”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-statusbar”: {},
“cordova-plugin-whitelist”: {},
“ionic-plugin-keyboard”: {},
“cordova-plugin-camera”: {},
“cordova-plugin-file-transfer”: {},
“cordova-plugin-file”: {},
“cordova-plugin-ionic-webview”: {
“ANDROID_SUPPORT_ANNOTATIONS_VERSION”: “27.+”
},
“cordova-plugin-ionic-keyboard”: {}
},
“platforms”: [
“android”,
“ios”
]
}
}