Cordova-plugin-firebase: Build fail: "Error: invalid data, chunk must be a string or buffer, not object"

Created on 12 Jul 2017  ·  15Comments  ·  Source: arnesson/cordova-plugin-firebase

I've been trying to integrate this plugin via ionic-native as per the instructions on https://ionicframework.com/docs/native/firebase/. However, when I build the project, it fails with the following terminal output:

cordova build ios
✖ Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build ios (exit code 1):

    Error: Invalid data, chunk must be a string or buffer, not object

jon-bongato:fbtest jbongato$ (node:11653) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: channel closed
(node:11653) 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.

I've been trying to set this up on a blank project, and even downloaded the appropriate GoogleService-Info.plist and google-services.json files into the project root folder. Has anybody encountered this issue before?

Most helpful comment

After what @jurevert said. What I realize is (in my case at least) -> Inside platforms/ios/" + name + "/Resources folder there isn't another Resources folder. I create the folder and the after_prepare.js runs normally (whithout comment the code).

All 15 comments

Hi,
I'm facing same issue by launching:
ionic cordova platform add ios when cordova-plugin-firebase is present.

After launching following to have more details:
cordova platform add ios -d

Logs are:

Error: TypeError: Invalid data, chunk must be a string or buffer, not object
at WriteStream.Socket.write (net.js:648:11)
at WriteStream.stream.write (/usr/local/lib/node_modules/cordova/node_modules/ansi/lib/newlines.js:36:21)
at Object. (/Users/koko/Documents/MyProject/plugins/cordova-plugin-firebase/scripts/after_prepare.js:46:24)

After commenting line 44 in /Users/koko/Documents/MyProject/plugins/cordova-plugin-firebase/scripts/after_prepare.js:

fs.writeFileSync("platforms/ios/" + name + "/Resources/Resources/GoogleService-Info.plist", contents)

This line was added here: https://github.com/arnesson/cordova-plugin-firebase/commit/9eecdf9c814cad4e3588ed23276da1b76b4be438#diff-72a71e008be841d1434336ffb4cd13dc by @erikdju

The 'add platform' comand succeed buy not sure that everything will working well now...

After what @jurevert said. What I realize is (in my case at least) -> Inside platforms/ios/" + name + "/Resources folder there isn't another Resources folder. I create the folder and the after_prepare.js runs normally (whithout comment the code).

Adding the extra "Resources" folder in my platforms/ios/+ name +/Resources folder worked!

Thanks @dobbinx3 & @jurevert!

Confirming the extra "Resources" folder on the ios platform folder fixes the issue.

hi all, i have the same issue, but i find a bug in after_prepare (46) 👍
var contents = fs.readFileSync(paths[i]).toString();
fs.writeFileSync("platforms/ios/" + name + "/Resources/GoogleService-Info.plist", contents)
//fs.writeFileSync("platforms/ios/" + name + "/Resources/Resources/GoogleService-Info.plist", contents)

@mobicraft-am I don't know if the newest versions of cordova create this second Resources folder. But in my pull request #351 I verify if the folder is there, and if there isn't, I create it. But it would be nice to know if this second Resources folder is really necessary.

With the latest cordova, this second Resources folder don’t exist.
All is running like a charm on my ionic3 project if a remove this line and of course i don’t create this second Resources folder … ;)

Le 28 juil. 2017 à 15:16, Dobbin notifications@github.com a écrit :

@mobicraft-am https://github.com/mobicraft-am I don't know if the newest versions of cordova create this second Resources folder. But in my pull request #351 https://github.com/arnesson/cordova-plugin-firebase/pull/351 I verify if the folder is there, and if there isn't, I create it. But it would be nice to know if this second Resources folder is really necessary.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/arnesson/cordova-plugin-firebase/issues/349#issuecomment-318649039, or mute the thread https://github.com/notifications/unsubscribe-auth/ASvttWHtCs3NVTS9O7NYnJvCmH8_djvqks5sSd8ngaJpZM4OWCc4.

We should ask @erikdju

Why did you create the code to copy the .plist file to this second Resources folder?

I resolve same problem removing from project name non-Latin characters
Problem appeared only with ios platform.
I think bug in this place cordova-plugin-firebase/scripts/after_prepare.js

var name = getValue(config, "name")
.....
try {
var contents = fs.readFileSync(paths[i]).toString();
fs.writeFileSync("platforms/ios/" + name + "/Resources/GoogleService-Info.plist", contents)
} catch(err) {
process.stdout.write(err);
}

@asmgit use 0.1.23 version

This bug is fixed on it.

I use 0.1.23 version
just before yesterday install

In my case I was having this problem with cordova-plugin-fcm and I did something similar to @asmgit . I just commented that line and copied the file manually, more details here

Hope this can help.

In my case, adding the res directory solved the problem. I was dealing with Android, not IOS.

@rpcarnell It seems there is no /res folder in my Android root directory as well. Did you only add the res directory? and nothing inside?

@darshantejani007 Instead of copying /res folder change path in plugins/cordova-plugin-fcm/scripts/fcm_config_files_process.js. see 481#issuecomment-376008472

Was this page helpful?
0 / 5 - 0 ratings