Getting error in package Android build.
Failed to restore plugin "cordova-plugin-ionic" from config.xml
Saved plugin info for "cordova-plugin-ionic" to config.xml
Failed to restore plugin "cordova-plugin-ionic" from config.xml. You might need to try adding it again. Error: TypeError: Invalid data, chunk must be a string or buffer, not object
(node:1) UnhandledPromiseRejectionWarning: TypeError: Invalid data, chunk must be a string or buffer, not object
at Socket.write (net.js:714:11)
at Socket.stream.write (/usr/local/lib/node_modules/cordova/node_modules/ansi/lib/newlines.js:36:21)
at Object. (/usr/src/app/plugins/cordova-plugin-fcm/scripts/fcm_config_files_process.js:80:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cordova platform add android --no-fetch failed
Running after script...
$ run "clean-up"
Running Stage clean-up for Job: 5622469
ERROR: Job failed: exit status 1
Build failedJob ID: 5622469
Android - debug build
Build failed!
I already followed these steps..
Delete the app's node_modules/ dir
Delete the app's package-lock.json file (if present)
Delete the app's platforms/ dir
Delete the app's plugins/ dir
Run npm install
Run npm run build
(everything works yet!)
But, it gives same error while running - ionic cordova platform add android
Attached image for ..
1. Error message
2. Ionic info
An answered from the Ionic support team has solved my problem.
The root of the problem here is cordova-plugin-fcm. That plugin hasn't been updated in a long time and likely doesn't support cordova-android 7.0.0+.
First thing to try: revert to cordova-android 6.4.0 and retry your build. That may allow the fcm plugin to install correctly and not interfere with the directory structure of the project.
Alternatively (and in general), I'd recommend switching to cordova-plugin-firebase which offers the same functionality and is actively maintained.
The underlying directory structure of the Android platform changed with cordova-android 7.0. This can cause issues when you have plugins that haven't been adjusted for use with the new structure.
Give one of those options a try.
And it worked! Revert to cordova-android 6.4.0 and retry build was the solution to the problem.