Errors when trying to build my project

Hello…
I’m having lots of issues when trying to build any of my projects using “ionic cordova build android” or "ionic cordova build android --prod"
With the first command I get the error Execution failed for task ‘:packageDebug’. > !zip.isFile()
With the second one I get the error FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Several days ago this two commands were working perfectly but now I’m unable to build any of my projects. Using “ionic serve -l” they work perfect but I need to build my release package.
Any suggestions???
Thanx…

Post your complete ionic info output please.

Also post the complete output you get running these two commands, add --verbose when running them.

My ionic info
cli packages: (D:\Ionic\WooIonic\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : android 6.2.3 browser 4.1.0
Ionic Framework    : ionic-angular 3.4.2

System:

Node : v6.11.0
npm  : 3.10.10
OS   : Windows 10

Using the --verbose flag…

PS D:\Ionic\WooIonic> ionic cordova build android --verbose
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'D:\\Ionic\\WooIonic', local: true, binPath:
        'C:\\Users\\MDC\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'D:\\Ionic\\WooIonic\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 12144)
[WARN] Detected @ionic/cli-plugin-cordova in your package.json.

       As of CLI 3.8, it is no longer needed. You can uninstall it:

       npm uninstall --save-dev --save-exact @ionic/cli-plugin-cordova

[WARN] Detected @ionic/cli-plugin-ionic-angular in your package.json.

       As of CLI 3.8, it is no longer needed. You can uninstall it:

       npm uninstall --save-dev --save-exact @ionic/cli-plugin-ionic-angular

[INFO] Running app-scripts build: --platform android --target cordova

[17:40:48]  build dev started ...
[17:40:48]  clean started ...
[17:40:48]  clean finished in 16 ms
[17:40:48]  copy started ...
[17:40:48]  transpile started ...
[17:40:50]  transpile finished in 2.31 s
[17:40:50]  preprocess started ...
[17:40:50]  deeplinks started ...
[17:40:51]  deeplinks finished in 100 ms
[17:40:51]  preprocess finished in 100 ms
[17:40:51]  webpack started ...
[17:40:51]  copy finished in 2.61 s
[17:41:16]  webpack finished in 25.52 s
[17:41:16]  sass started ...
[17:41:17]  sass finished in 855 ms
[17:41:17]  postprocess started ...
[17:41:17]  removed unused font files
[17:41:17]  postprocess finished in 15 ms
[17:41:17]  lint started ...
[17:41:17]  build dev finished in 28.88 s
> ionic cordova prepare
> cordova prepare
\ Running command [17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/cart/cart.ts, line: 99
            Unused variable: 'price'

      L98:  //  this.cartItems.
      L99:    let price = item.product.price;
     L100:    let qty = item.qty;

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/cart/cart.ts, line: 100
            Unused variable: 'qty'

      L99:  let price = item.product.price;
     L100:  let qty = item.qty;
     L101:  this.total = 0.0;

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/cart/cart.ts, line: 117
| Running command             Unused variable: 'price'

     L116:  decreaseCartValue(item, i){
     L117:    let price = item.product.price;
     L118:    let qty = item.qty;

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/cart/cart.ts, line: 118
            Unused variable: 'qty'

     L117:  let price = item.product.price;
     L118:  let qty = item.qty;
     L119:  this.total = 0.0;

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/menu/menu.ts, line: 2
            Unused import: 'Content'

       L1:  import { Component, ViewChild } from '@angular/core';
       L2:  import { Content, IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';
       L3:  //import { HomePage } from '../home/home';

[17:41:20]  tslint: D:/Ionic/WooIonic/src/app/app.component.ts, line: 8
            Unused import: 'Menu'

       L8:  import { Menu } from '../pages/menu/menu';
       L9:  //import { Signup } from '../pages/signup/signup';

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/categories/categories.ts, line: 1
            Unused import: 'ViewChild'

       L1:  import { Component, ViewChild } from '@angular/core';
       L2:  import { IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/home/home.ts, line: 8
            Unused import: 'AccordionComponent'

       L7:  import { Global } from '../../global';
       L8:  import { AccordionComponent } from '../../components/accordion/accordion';

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/order-details/order-details.ts, line: 3
            Unused import: 'Global'

       L2:  import { IonicPage, NavController, NavParams } from 'ionic-angular';
       L3:  import { Global } from '../../global';

[17:41:20]  tslint: D:/Ionic/WooIonic/src/pages/product-details/product-details.ts, line: 11
            Unused import: 'AccordionComponent'

      L10:  import { PhotoViewer } from '@ionic-native/photo-viewer';
      L11:  import { AccordionComponent } from '../../components/accordion/accordion';

[17:41:20]  lint finished in 2.64 s
√ Running command - done!

> cordova build android
× Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):


        (truncated) ... ovaLib:processDebugResources UP-TO-DATE
        :CordovaLib:generateDebugSources UP-TO-DATE
        :CordovaLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
        :CordovaLib:processDebugJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
        :CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
        :CordovaLib:bundleDebug UP-TO-DATE
        :CordovaLib:preReleaseBuild UP-TO-DATE
        :CordovaLib:checkReleaseManifest
        :CordovaLib:prepareReleaseDependencies
        :CordovaLib:compileReleaseAidl UP-TO-DATE
        :CordovaLib:compileReleaseNdk UP-TO-DATE
        :CordovaLib:copyReleaseLint UP-TO-DATE
        :CordovaLib:mergeReleaseShaders UP-TO-DATE
        :CordovaLib:compileReleaseShaders UP-TO-DATE
        :CordovaLib:generateReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
        :CordovaLib:packageReleaseRenderscript UP-TO-DATE
        :CordovaLib:compileReleaseRenderscript UP-TO-DATE
        :CordovaLib:generateReleaseResValues UP-TO-DATE
        :CordovaLib:generateReleaseResources UP-TO-DATE
        :CordovaLib:packageReleaseResources UP-TO-DATE
        :CordovaLib:processReleaseManifest UP-TO-DATE
        :CordovaLib:generateReleaseBuildConfig UP-TO-DATE
        :CordovaLib:processReleaseResources UP-TO-DATE
        :CordovaLib:generateReleaseSources UP-TO-DATE
        :CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
        :CordovaLib:processReleaseJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
        :CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
        :CordovaLib:bundleRelease UP-TO-DATE
        :prepareComAndroidSupportAnimatedVectorDrawable2531Library UP-TO-DATE
        :prepareComAndroidSupportAppcompatV72531Library UP-TO-DATE
        :prepareComAndroidSupportCardviewV72531Library UP-TO-DATE
        :prepareComAndroidSupportCustomtabs2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportCompat2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUi2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUtils2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportFragment2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportMediaCompat2531Library UP-TO-DATE
        :prepareComAndroidSupportSupportV42531Library UP-TO-DATE
        :prepareComAndroidSupportSupportVectorDrawable2531Library UP-TO-DATE
        :prepareComCommit451PhotoView124Library UP-TO-DATE
        :prepareComFacebookAndroidFacebookAndroidSdk4250Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBase1104Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBasement1104Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesGcm1104Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesIid1104Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesLocation1104Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesTasks1104Library UP-TO-DATE
        :prepareComOnesignalOneSignal357Library UP-TO-DATE
        :prepareComPaypalSdkPaypalAndroidSdk2153Library UP-TO-DATE
        :prepareIoCardAndroidSdk540Library UP-TO-DATE
        :prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
        :prepareDebugDependencies
        :compileDebugAidl UP-TO-DATE
        :compileDebugRenderscript UP-TO-DATE
        :generateDebugBuildConfig UP-TO-DATE
        :generateDebugResValues UP-TO-DATE
        :generateDebugResources UP-TO-DATE
        :mergeDebugResources UP-TO-DATE
        :processDebugManifest UP-TO-DATE
        :processDebugResources UP-TO-DATE
        :generateDebugSources UP-TO-DATE
        :incrementalDebugJavaCompilationSafeguard UP-TO-DATE
        :compileDebugJavaWithJavac UP-TO-DATE
        :compileDebugNdk UP-TO-DATE
        :compileDebugSources UP-TO-DATE
        :mergeDebugShaders UP-TO-DATE
        :compileDebugShaders UP-TO-DATE
        :generateDebugAssets UP-TO-DATE
        :mergeDebugAssets UP-TO-DATE
        :transformClassesWithDexForDebug UP-TO-DATE
        :mergeDebugJniLibFolders UP-TO-DATE
        :transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
        :processDebugJavaRes UP-TO-DATE
        :transformResourcesWithMergeJavaResForDebug UP-TO-DATE
        :validateSigningDebug
        :packageDebug FAILED

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':packageDebug'.
        > !zip.isFile()

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

        BUILD FAILED

        Total time: 12.993 secs
        Error: cmd: Command failed with exit code 1 Error output:
        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':packageDebug'.
        > !zip.isFile()

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Most often these can be fixed by opening the Android project in Android Studio and then clean the project. Maybe even cordova clean android is enough: CLI Commands - Apache Cordova

10 Likes

That seems to work… And what about the error when using

Getting FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory???

Run with --verbose added at the end, post the complete output.

The --verbose output with --prod flag


[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'D:\\Ionic\\WooIonic', local: true, binPath:
        'C:\\Users\\MDC\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'D:\\Ionic\\WooIonic\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 12144)
[WARN] Detected @ionic/cli-plugin-cordova in your package.json.

       As of CLI 3.8, it is no longer needed. You can uninstall it:

       npm uninstall --save-dev --save-exact @ionic/cli-plugin-cordova

[WARN] Detected @ionic/cli-plugin-ionic-angular in your package.json.

       As of CLI 3.8, it is no longer needed. You can uninstall it:

       npm uninstall --save-dev --save-exact @ionic/cli-plugin-ionic-angular

[INFO] Running app-scripts build: --prod --platform android --target cordova

[18:20:49]  build prod started ...
[18:20:49]  clean started ...
[18:20:49]  clean finished in less than 1 ms
[18:20:49]  copy started ...
[18:20:49]  ngc started ...
[18:20:57]  ngc finished in 8.25 s
[18:20:57]  preprocess started ...
[18:20:57]  deeplinks started ...
[18:20:58]  deeplinks finished in 672 ms
[18:20:58]  optimization started ...
[18:20:58]  copy finished in 9.19 s
[18:21:14]  optimization finished in 15.87 s
[18:21:14]  preprocess finished in 16.55 s
[18:21:14]  webpack started ...

<--- Last few GCs --->

   97270 ms: Mark-sweep 1081.6 (1436.4) -> 1081.6 (1436.4) MB, 808.7 / 0.0 ms [allocation failure] [GC in old space requested].
   98082 ms: Mark-sweep 1081.6 (1436.4) -> 1081.6 (1436.4) MB, 811.7 / 0.0 ms [allocation failure] [GC in old space requested].
   98959 ms: Mark-sweep 1081.6 (1436.4) -> 1098.0 (1418.4) MB, 877.2 / 0.0 ms [last resort gc].
   99777 ms: Mark-sweep 1098.0 (1418.4) -> 1114.7 (1418.4) MB, 817.1 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000003D0305CFB49 <JS Object>
    1: addMapping(aka SourceMapGenerator_addMapping) [D:\Ionic\WooIonic\node_modules\source-map\lib\source-map-generator.js:~94] [pc=000003DFCF0B65CB] (this=00000214117BD8B9 <a SourceMapGenerator with map 00000242968F37B9>,aArgs=000001DD4DCEEA71 <an Object with map 00000242968F34A1>)
    2: /* anonymous */ [D:\Ionic\WooIonic\node_modules\source-map\lib\source-node.js:345] [pc=000003DFCF0968C9...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Webpack seems to require too much space to finish. No idea what to do about it though, sorry.

Thanks anyway… I have 8GB of RAM and, as I told you before, I’m getting this error since a few days. Before that everything was OK. I’ll keep trying to fix this.
Again… Thank you very much!!!

I made some changes to ionic.cmd file. Now it looks like this…

@IF EXIST “%~dp0\node.exe” (
"%~dp0\node.exe --max_old_space_size=10240" “%~dp0\node_modules\ionic\bin\ionic” %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=10240 “%~dp0\node_modules\ionic\bin\ionic” %*
)
And it seems to be solved the problem so far.

1 Like

cordova clean android worked for me. Thanks!

5 Likes

Thx your @wcustodio I faced the same error (after having updated my android libs and restarted my mac) and running the clean cmd solved my issue :heart:

This really helped, Thanks a Ton!
cordova clean android

Thanks man,
Works for me.
thanks for sharing.

thanks dear , also worked for me.