Ionic cordova resources --splash and --icon error

2020-03-01 05:28发布

问题:

I´m getting this error on resources generator:
Error: end() has already been called, so it's too late to start piping

I´m stuck with this error. Shows up when I try to generate resources:

PS F:\Desenvolvimento\Ionic\Divas> ionic cordova resources ios -f
√ Collecting resource configuration and source images - done!
√ Filtering out image resources that do not need regeneration - done!
√ Uploading source images to prepare for transformations: 2 / 2 complete - done!
- Generating platform resources: 8 / 32 complete
C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic\node_modules\superagent\lib\node\index.js:859
      throw Error("end() has already been called, so it's too late to start piping");
      ^

Error: end() has already been called, so it's too late to start piping
    at Response.response.pipe (C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic\node_modules\superagent\lib\node\index.js:859:13)
    at Request.req.type.send.on.res (C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic\lib\integrations\cordova\resources.js:166:25)
    at Request.emit (events.js:182:13)
    at Request._emitResponse (C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic\node_modules\superagent\lib\node\index.js:862:8)
    at ClientRequest.req.once.res (C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic\node_modules\superagent\lib\node\index.js:412:10)
    at Object.onceWrapper (events.js:273:13)
    at ClientRequest.emit (events.js:187:15)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
    at TLSSocket.socketOnData (_http_client.js:442:20)

My system:

Ionic:

   ionic (Ionic CLI)  : 4.7.1 (C:\Users\Gustavo\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : not installed
   Cordova Platforms     : android 6.3.0
   Cordova Plugins       : cordova-plugin-ionic-webview 1.1.1, (and 8 other plugins)

System:

   NodeJS : v10.15.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.5.0
   OS     : Windows 10

回答1:

It looks like my image was incorrectly sized. I created a new image with larger sizes and it worked. Strange that there was no message about it.



回答2:

I was getting the exact same error. I noticed my icon.png (the one I created) was 1024x916 and it didn't like it. I resized it to be exactly 1024x1024 and now it works!!!



回答3:

Splash-Screen have to be 2732×2732px (look here: https://ionicframework.com/docs/cli/cordova/resources/)



回答4:

The source icons should ideally be at least 1024×1024px and located at resources/icon.png. The source image for splash screens should ideally be at least 2732×2732px and located at resources/splash.png.



回答5:

There is a problem with your version of ionic where the exact error in resource generation is not recorded. I think this is not yet a known bug.

For now, you can run npm i -g ionic@3, then run the command again. This will tell you the error message. Once you're done, run npm i -g ionic again to update to Ionic 4.



回答6:

Just resize

  1. icon as 1024x1024
  2. splash as 2732x2732

Then run:-

  1. ionic cordova resources.
  2. ios ionic cordova resources android.

As per the docs The source image for icons should ideally be at least 1024×1024px and located at resources/icon.png. The source image for splash screens should ideally be at least 2732×2732px and located at resources/splash.png.



回答7:

I got the same error on linux:

My new icon used alpha channel (my mistake) and i got this error. When i saw this thread, i understood this tool could be very sensible. My icon (old & new) was 512*512. My spash was 2300*2400. => Putting all image to the correct size had no effect. 'flattening' my image using gimp was the solution.

My conclusion : don't use alpha channel in your images



回答8:

remove your splash.png and icon.png file from resources then First convert your splash and icon image as per requirement enter link description here then copy and replace converted images to resources directory,and then do ionic cordova resources only do not need to add platform ionic will make resources automatically.