Is is mandatory to put --prod while build APK?

Hi Experts,

I was able to build my apk with --prod tag before firebase latest update but June 2019 onwards it is consistently throwing some error. Tried all the solutions available online but nothing worked.

Now i realize that if i build the APK without --prod tag and with --release then i am able to build it. So my question is that is it mandatory to have --prod tag? If yes then what are the benefits?

Please help.

Hi

I believe the --prod is not mandory although desirable in production situation given for instance environment setup in angular (enableProdMode) and other best practices in separating environment (like firebase configs, one for prod one for uat etc).

Next, --prod will do some additional processing on your code making smaller bundles and some performance improvements, minifying etc. All magic to me, but somehow needed for prod.

So, depends on what you want to use the apk for, but in the end you will probably end up using it anyway.

Tom
Not an expert

Thanks for the quick revert Tom. My understanding regarding --prod was the same. But as soon as i use this to build APK, it throws following error:

[21:04:10]  ionic-app-script task: "build"
[21:04:10]  TypeError: Object prototype may only be an Object or null: undefined
TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at Object.__extends (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/tslib/tslib.js:64:9)
    at /Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:115:17
    at /Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:314:6
    at Object.defineProperty.value (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:3:17)
    at Object.<anonymous> (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:9:3)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
[ERROR] An error occurred while running subprocess ionic-app-scripts.

        ionic-app-scripts build --prod --target cordova --platform android exited with exit code 1.

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

and if you run ionic build --prod ?

so skip the apk part and debug the ionic build first as the --prod flag relates to ng/ionic?

you could chose to add --verbose to read a bit more

Here is the response:

ionic build --prod --verbose
  ionic:bootstrap local CLI 3.6.0 found at /Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/ionic/package.json +0ms
  ionic:lib Terminal info: { ci: false, shell: '/bin/zsh', tty: true, windows: false } +0ms
  ionic:lib CLI global options: { _: [ 'build' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, prod: true, project: null, '--': [] } +2ms
[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.
  ionic:lib:project Project type from config: Ionic 2/3 (ionic-angular) +0ms
  ionic:lib:project Project details: { configPath: '/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/ionic.config.json', errors: [], context: 'app', type: 'ionic-angular' } +1ms
[WARN] The pro_id field in ./ionic.config.json has been deprecated.

       Ionic Pro has been renamed to Ionic Appflow! We've copied the value in pro_id to id, but you may want to unset
       the deprecated property: ionic config unset pro_id

  ionic Context: { binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/usr/local/lib/node_modules/ionic', execPath: '/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3', version: '5.2.6' } +0ms
  ionic:lib:build build options: { '--': [],
  ionic:lib:build   engine: 'browser',
  ionic:lib:build   platform: undefined,
  ionic:lib:build   project: undefined,
  ionic:lib:build   verbose: true,
  ionic:lib:build   type: 'ionic-angular',
  ionic:lib:build   prod: true,
  ionic:lib:build   sourcemaps: undefined,
  ionic:lib:build   aot: false,
  ionic:lib:build   minifyjs: false,
  ionic:lib:build   minifycss: false,
  ionic:lib:build   optimizejs: false,
  ionic:lib:build   env: undefined } +0ms
  ionic:lib:telemetry Sending telemetry for command: 'ionic build' [ '--prod', '--verbose', '--interactive', '--color' ] +0ms
  ionic:lib:hooks Looking for ionic:build:before npm script. +0ms
  ionic:lib:project:ionic-angular:build Looking for ionic:build npm script. +0ms
> ionic-app-scripts build --prod
[21:31:36]  ionic-app-scripts 3.2.4
[21:31:36]  build prod started ...
[21:31:36]  clean started ...
[21:31:36]  clean finished in 12 ms
[21:31:36]  copy started ...
[21:31:36]  deeplinks started ...
[21:31:37]  deeplinks finished in 756 ms
[21:31:37]  ngc started ...
[21:31:41]  ionic-app-script task: "build"
[21:31:41]  TypeError: Object prototype may only be an Object or null: undefined
TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at Object.__extends (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/tslib/tslib.js:64:9)
    at /Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:115:17
    at /Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:314:6
    at Object.defineProperty.value (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:3:17)
    at Object.<anonymous> (/Users/ankitkau/WorkDocs/Ankit Kaushik/ionic/mapskool-ionic3/node_modules/@angular/compiler-cli/src/ngtsc/indexer/src/template.js:9:3)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
[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.
  ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
  ionic:utils-process onBeforeExit handler: running 1 functions +0ms
  ionic:utils-process processExit: exiting (exit code: 1) +65ms

Well, maybe google a bit around …

and others…

I did. But not able to make out anything from these links. :frowning:

then i would go and build a new project and copy/paste code step by step, either a new ionic3 project or ionic 4

Sure. Let me try that.

Strangely if i run “cordova build android --prod” then it works.