Problem with $ ionic cordova run android --prod

Hi. I would like to generate the production apk of my app with the commands

$ ionic cordova build android --prod 
and
$ ionic cordova run android --prod

but these commands gives me some errors. The entire output it’s here: https://pastebin.com/iygWpnxY
These are two error details of the ouput:


Error: ./node_modules/tslib/tslib.es6.js
Module build failed: TypeError: Cannot read property 'type' of undefined
at Object.getEffectiveTypeAnnotationNode
[....]
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\gitlab\veneto-app\src\app'
resolve './app.module.ngfactory'

I’ve tryied to google this problem but I’ve found only similar errors with solution that are not usefull for me. How can I resolve this problem?

Thank you in advance :slight_smile:

The commands you posted do a “optimized production build”, but if you want to do an actual release build to be published you also have to add --release.

What is your ionic info output?

sorry maybe I used the wrong words…I would like to generate the --prod apk so I can try on my device this type of apk, for example for testing if the white screen after the slash screen it’s gone or not. I don’t want to release my app on the stores yet, I’m still developing and testing the app.

If I add --release and run $ ionic cordova run android --prod --release I have the same identical errors.

This is my ionic-info

cli packages: (C:\Users\erica\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.4.0 browser 5.0.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.11.3
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\erica\AppData\Local\Android\Sdk

Misc:

    backend : pro

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

I’ve tryied to update to 7.0.0 but nothing changed…

If you read the link I posted, you will learn that the current version of cordova-android is 7.1.1. No use continue debugging before you are using that versoin and post the ionic info and output of the failing command then.

Ok I’ve uploaded to cordova-android 7.1.1
this is my ionic info

cli packages: (C:\Users\erica\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:
    cordova (Cordova CLI) : 8.0.0

local packages:
    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 7.1.1 browser 5.0.4
    Ionic Framework    : ionic-angular 3.9.2

System:
    Android SDK Tools : 26.1.1
    Node              : v8.11.3
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:
    ANDROID_HOME : C:\Users\erica\AppData\Local\Android\Sdk

Misc:
    backend : pro

After I run $ ionic cordova build android --prod I obtain this 0utput (the same that I’ve posted in my question.)

$ ionic cordova build android --prod
Running app-scripts build: --prod --platform android --target cordova
[14:52:10]  build prod started ...
[14:52:10]  clean started ...
[14:52:10]  clean finished in 16 ms
[14:52:10]  copy started ...
[14:52:10]  deeplinks started ...
[14:52:10]  deeplinks finished in 125 ms
[14:52:10]  ngc started ...
[14:52:21]  ngc finished in 10.89 s
[14:52:21]  preprocess started ...
[14:52:21]  preprocess finished in less than 1 ms
[14:52:21]  webpack started ...
[14:52:24]  copy finished in 14.11 s
Error: ./node_modules/tslib/tslib.es6.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:9341:18)
    at assignContextualParameterTypes (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42959:28)
    at checkExpression (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42898:42)
    at checkBinaryLikeExpression (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42475:29)
    at checkBinaryExpression (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42467:20)
    at checkExpressionWorker (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42980:28)
    at checkExpression (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42898:42)
    at checkBinaryLikeExpression (C:\gitlab\veneto-app\node_modules\typescript\lib\typescript.js:42475:29)
 @ ./node_modules/@angular/platform-browser/esm5/platform-browser.js 9:0-44
 @ ./src/app/main.ts,./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\gitlab\veneto-app\src\app'
resolve './app.module.ngfactory' in 'C:\gitlab\veneto-app\src\app'
  using description file: C:\gitlab\veneto-app\package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: C:\gitlab\veneto-app\package.json (relative path: ./src/app)
    using description file: C:\gitlab\veneto-app\package.json (relative path: ./src/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        C:\gitlab\veneto-app\src\app\app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        C:\gitlab\veneto-app\src\app\app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        C:\gitlab\veneto-app\src\app\app.module.ngfactory.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        C:\gitlab\veneto-app\src\app\app.module.ngfactory.json doesn't exist
      as directory
        C:\gitlab\veneto-app\src\app\app.module.ngfactory doesn't exist
[C:\gitlab\veneto-app\src\app\app.module.ngfactory]
[C:\gitlab\veneto-app\src\app\app.module.ngfactory.ts]
[C:\gitlab\veneto-app\src\app\app.module.ngfactory.js]
[C:\gitlab\veneto-app\src\app\app.module.ngfactory.json]
[C:\gitlab\veneto-app\src\app\app.module.ngfactory]
 @ ./src/app/main.ts 2:0-60
    at new BuildError (C:\gitlab\veneto-app\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
    at callback (C:\gitlab\veneto-app\node_modules\@ionic\app-scripts\dist\webpack.js:121:28)
    at emitRecords.err (C:\gitlab\veneto-app\node_modules\webpack\lib\Compiler.js:265:13)
    at Compiler.emitRecords (C:\gitlab\veneto-app\node_modules\webpack\lib\Compiler.js:371:38)
    at emitAssets.err (C:\gitlab\veneto-app\node_modules\webpack\lib\Compiler.js:258:10)
    at applyPluginsAsyncSeries1.err (C:\gitlab\veneto-app\node_modules\webpack\lib\Compiler.js:364:12)
    at next (C:\gitlab\veneto-app\node_modules\tapable\lib\Tapable.js:218:11)
    at Compiler.compiler.plugin (C:\gitlab\veneto-app\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (C:\gitlab\veneto-app\node_modules\tapable\lib\Tapable.js:222:13)
    at Compiler.afterEmit (C:\gitlab\veneto-app\node_modules\webpack\lib\Compiler.js:361:9)

Thank you in advance for your help!

Good.

Upgrade this, there is both a 3.1.11 and a 3.2.0 available.

Can you build a new project started with ionic start?

Finally I was able to solve the problem.
these are my steps:

Npm install @ionic/app-scripts@latest
npm install firebase@4.12.1

And all worked

Try

@ionic/app-scripts”: “^3.2.4”,
“typescript”: “2.4.2”

Works for me