Error: ionic cordova build android --prod --release

Hi guys.
I want get apk production.
When I run command ionic cordova build android --prod --release, I get this error:

> ionic-app-scripts build --prod --target cordova --platform android
[12:47:49]  ionic-app-scripts 3.1.11
[12:47:49]  build prod started ...
[12:47:49]  clean started ...
[12:47:49]  clean finished in 2 ms
[12:47:49]  copy started ...
[12:47:51]  deeplinks started ...
[12:47:51]  deeplinks finished in 191 ms
[12:47:51]  ngc started ...
[12:47:57]  typescript error
            Type AboutPage in D:/EmekMecellesi/src/pages/about/about.ts is part of the declarations of 2 modules:
            AppModule in D:/EmekMecellesi/src/app/app.module.ts and AboutPageModule in
            D:/EmekMecellesi/src/pages/about/about.module.ts! Please consider moving AboutPage in
            D:/EmekMecellesi/src/pages/about/about.ts to a higher module that imports AppModule in
            D:/EmekMecellesi/src/app/app.module.ts and AboutPageModule in
            D:/EmekMecellesi/src/pages/about/about.module.ts. You can also create a new NgModule that exports and
            includes AboutPage in D:/EmekMecellesi/src/pages/about/about.ts then import that NgModule in AppModule in
            D:/EmekMecellesi/src/app/app.module.ts and AboutPageModule in
            D:/EmekMecellesi/src/pages/about/about.module.ts.

[12:47:57]  ionic-app-script task: "build"
[12:47:57]  Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
    at D:\EmekMecellesi\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
    at step (D:\EmekMecellesi\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (D:\EmekMecellesi\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
    at fulfilled (D:\EmekMecellesi\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
    at <anonymous>
[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.
events.js:165
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer
    at validChunk (_stream_writable.js:257:10)
    at WriteStream.Writable.write (_stream_writable.js:292:21)
    at process.<anonymous> (C:\Users\TaGi-PC\AppData\Roaming\npm\node_modules\ionic\bin\ionic:9:63)
    at process.emit (events.js:180:13)
    at emitPromiseRejectionWarnings (internal/process/promises.js:102:20)
    at process._tickCallback (internal/process/next_tick.js:183:42)
Emitted 'error' event at:
    at validChunk (_stream_writable.js:261:12)
    at WriteStream.Writable.write (_stream_writable.js:292:21)
    [... lines matching original stack trace ...]
    at process._tickCallback (internal/process/next_tick.js:183:42)

my ionic info:

Ionic:

   ionic (Ionic CLI)  : 4.1.0 (C:\Users\TaGi-PC\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.1, (and 5 other plugins)

System:

   Android SDK Tools : 25.2.5
   NodeJS            : v9.11.1 (C:\Program Files\nodejs\node.exe)
   npm               : 5.6.0
   OS                : Windows 8.1

Environment:

   ANDROID_HOME : C:\Users\TaGi-PC\AppData\Local\Android\sdk
1 Like

Has anyone found a solution for this? I am having exact same errors

Try removing the AboutPage in the declarations of AppModule and instead try importing the AboutPageModule in imports of the AppModule. Building for production is a strict one.

1 Like
ionic cordova build --release android

try this

1 Like

This fixed it. Thanks a lot.:+1:

It did not work …:tired_face:

what problem are you exactly facing ?

Hi,
I have solved the problem. I reinstall cordova and everything run ok.
Thank you so much. Hope to talk to you soon