Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fail: "Error: invalid data, chunk must be a string or buffer, not object" #349

Closed
jonbongato opened this issue Jul 12, 2017 · 15 comments

Comments

@jonbongato
Copy link

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?

@jurevert
Copy link

jurevert commented Jul 12, 2017

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: 9eecdf9#diff-72a71e008be841d1434336ffb4cd13dc by @erikdju

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

@rodrigodobbin
Copy link

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).

@jonbongato
Copy link
Author

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

Thanks @dobbinx3 & @jurevert!

@eruecco87-zz
Copy link

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

@mobicraft-am
Copy link
Contributor

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)

@rodrigodobbin
Copy link

@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.

@mobicraft-am
Copy link
Contributor

mobicraft-am commented Jul 28, 2017 via email

@rodrigodobbin
Copy link

We should ask @erikdju

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

@asmgit
Copy link

asmgit commented Aug 10, 2017

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);
}

@rodrigodobbin
Copy link

@asmgit use 0.1.23 version

This bug is fixed on it.

@asmgit
Copy link

asmgit commented Aug 11, 2017

I use 0.1.23 version
just before yesterday install

@walfro
Copy link

walfro commented Aug 16, 2017

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.

@rpcarnell
Copy link

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

@darshantejani007
Copy link

@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?

@hadi-aj
Copy link

hadi-aj commented Apr 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants