ionic-framework: App fails to build after upgrade to 3.8.0

Ionic version: [ ] 2.x [X] 3.x [ ] 4.x

I’m submitting a … [X] bug report [ ] feature request

Our App builds fine using Ionic 3.7.1, however fails to build with Ionic 3.8.0 due to dependency errors.

Steps to reproduce: ionic cordova build android --prod --release

Other information:

$ ionic cordova build android --prod --release
Running app-scripts build: --prod --platform android --target cordova
[11:06:29]  build prod started ... 
[11:06:29]  clean started ... 
[11:06:29]  clean finished in 3 ms 
[11:06:29]  copy started ... 
[11:06:29]  deeplinks started ... 
[11:06:29]  deeplinks finished in 208 ms 
[11:06:29]  ngc started ... 
Error: Metadata version mismatch for module /path/to/ionic/jzw-app-uc/node_modules/@ionic/storage/dist/src/storage.d.ts, found version 4, expected 3
    at StaticSymbolResolver.getModuleMetadata (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:25755:34)
    at StaticSymbolResolver._createSymbolsOf (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:25543:46)
    at StaticSymbolResolver.getSymbolsOf (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:25524:14)
    at /path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:24381:30
    at Array.forEach (native)
    at extractProgramSymbols (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:24380:79)
    at AotCompiler.analyzeModulesAsync (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler/bundles/compiler.umd.js:23936:47)
    at CodeGenerator.codegen (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler-cli/src/codegen.js:32:14)
    at Function.NgTools_InternalApi_NG_2.codeGen (/path/to/ionic/jzw-app-uc/node_modules/@angular/compiler-cli/src/ngtools_api.js:73:30)
    at Object.doCodegen (/path/to/ionic/jzw-app-uc/node_modules/@ionic/app-scripts/dist/aot/codegen.js:6:51)
[11:06:32]  copy finished in 3.05 s 

Ionic info:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.16.0
ionic (Ionic CLI) : 3.16.0

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.0.1
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.8.0

System:

ios-deploy : 1.9.2 
ios-sim    : 6.0.0 
Node       : v6.11.4
npm        : 5.5.1 
OS         : OS X El Capitan
Xcode      : Xcode 8.2.1 Build version 8C1002 

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (2 by maintainers)

Most upvoted comments

Issue is the result of ionic-storage 2.1.1 depending on Angular 5.x. Downgrading to ionic-storage 2.0.1 resolves the issue

i’m able to make a dev build. But the prod build fails with the above error

I have the same problem

ionic cordova build android --prod --release

Error: Metadata version mismatch for /node_modules/@ionic-native/core/decorators.d.ts, found version 4, expected 3

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.18.0
ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.0
Cordova Platforms  : android 6.3.0 ios 4.5.3
Ionic Framework    : ionic-angular 3.8.0

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2
ios-sim           : 6.1.2
Node              : v6.11.4
npm               : 5.5.1
OS                : macOS Sierra

removing current ionic-storage and installing v2.0.1 worked for me.

npm remove @ionic/storage then npm install --save @ionic/storage@2.0.1

Same problem with @ionic-native/status-bar and @ionic-native/splash-screen “… found version 4, expected version 3.”

This is not a problem w/dev builds, or running a debug version on a device. It is not a problem with ionic cordova build android --release. It is only a problem with --prod builds.

Doing an npm update seems to have solved the issue w/o downgrading anything. All my @ionic-native plugins are now at 4.5.2, and ionic cordova run android --prod works fine.

While the answers above provide temp potential fixes for individual plugins, they don’t explain or solve the underlying problem. Rollbacks mean using older/broken plugins instead of code that was updated for a reason - that’s a quick fix, but not an ideal solution.

My question is WHY is ngc for --prod builds expecting version 3 of various ionic-native plugins when package.json clearly says to use version ^4? Why & where is it looking for version 3 at all? Where does ngc compiler/build production process pull its information from? How can people solve the underlying issue instead of degrading their app’s functionality one outdated plugin at a time?

Thank for any insight ~

downgrading to @ionic-native to 4.3.3 was enough to make it work again for me. did not have to downgrade ionic 3.18.0 to 3.17.0. and indeed ionic doctor check was suggesting the upgrade and made it not work any more 😃

We just need to downgrade Ionic Native to 4.3.3. I have tried to upgrade dependencies separately and fround that this problem occurs in Ionic Native 4.4.0.

I just tried npm i --save -E @ionic-native/core@4.4.0, and it started to fail android --prod builds.

You can downgrade/stay at 4.3.3 using (any one/all depending upon what you have updated) -

npm i --save @ionic-native/core@4.3.3
npm i --save @ionic-native/device@4.3.3 
npm i --save @ionic-native/keyboard@4.3.3
npm i --save @ionic-native/splash-screen@4.3.3
npm i --save @ionic-native/status-bar@4.3.3

And you can install other updates separately.

And downgrade TS to 2.4.x. Angular does not support newer TS versions at this moment

Remove your Ionic dependency from your devDeps. The latest CLI is not required as a dependecy anymore.

You should also be able to just run npm install @ionic/storage@2.0.1 --save-exact.

Hay @jzwcars, I have my ionic-storage downgrade, still I’m getting same issue. Any solution for same.