Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "chunk" argument must be one of type string or Buffer. Received type object

I am trying to run the command to run my ionic 3 Command prompt. I used cordova fcm plugin.

ionic cordova run android

ERROR:

The "chunk" argument must be one of type string or Buffer. Received type object

Ionic:

ionic (Ionic CLI) : 4.10.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.6.0 @ionic/app-scripts : 2.1.4

Cordova:

cordova (Cordova CLI) : 8.1.2 ([email protected]) Cordova Platforms : android 7.1.4 Cordova Plugins : no whitelisted plugins (25 plugins total)

System:

NodeJS : v10.15.1 (/Users/sivakumarv/.nvm/versions/node/v10.15.1/bin/node) npm : 6.4.1 OS : macOS High Sierra Xcode : Xcode 10.1 Build version 10B61

Environment Variables:

ANDROID_HOME : C:\Users\pkhon\AppData\Local\Android\Sdk

like image 982
siva kumar Avatar asked May 27 '19 14:05

siva kumar


2 Answers

There is a bug in the plugin, to solve this: go to:

plugins/cordova-plugin-fcm/scripts/fcm_config_files_process.js

Now change the file like this:

// change
var strings = fs.readFileSync("platforms/android/res/values/strings.xml").toString();
// to
var strings = fs.readFileSync("platforms/android/app/src/main/res/values/strings.xml").toString();

// AND

//change
fs.writeFileSync("platforms/android/res/values/strings.xml", strings);

//to
fs.writeFileSync("platforms/android/app/src/main/res/values/strings.xml", strings);

After that, copy the google-services.json file to the following directories:

  • platforms/android/google-services.json
  • platforms/android/app/google-services.json

For more information, you can check this bug here

like image 87
asimhashmi Avatar answered Oct 16 '22 20:10

asimhashmi


Along with the changes mentioned above https://stackoverflow.com/a/56330922/5698147 by Asim Hashmi , also manually search & replace the firebase versions to

firebase-core:16.0.3
firebase-messaging:17.6.0

in

  • android/build.gradle
  • android/project.properties
  • android/app/build.gradle

Then run ionic cordova build android --prod

like image 20
Nishant Tamilselvan Avatar answered Oct 16 '22 22:10

Nishant Tamilselvan