0
votes

I'm trying to run my Ionic app in an Android device with cordova-plugin-fcm but I get the error below when I try to install it (cordova plugin add cordova-plugin-fcm) or run it (ionic cordova run android). The plugin is listed in cordova plugins despite of the error.

(node:2360) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Invalid data, chunk must be a string or buffer, not object (node:2360) [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.

Versions:

ionic CLI: 3.19.0

cordova: 8.0.0

cordova-android: 7.0.0

3
Note that the first and last line here aren't really relevant to your problem: they're warnings that are produced by node.js that indicate that cordova's using a node API that's going to change in a future version. That change hasn't happened yet, though, so the warning shouldn't actually be a problem. The middle line of your messages is the relevant one, and I'm afraid I can't help you with that one.Jules
The problem is that in Cordova version 8.0.0 Android platform has changed its structure so the plugin goes crazy because it can't find the file it needs. So there are 2 temporary solutions: 1. Downgrade Cordova 2. Downgrade Android platformFranSto

3 Answers

1
votes

problem is with the cordova-android version you have installed. I tried it with [email protected] and the plugin installed without any error

0
votes

With [email protected] the directory structure has change but downgrading shouldn't be an option.

Please check my comment for the issue in cordova-plugin-fcm GitHub repository: https://github.com/fechanique/cordova-plugin-fcm/issues/213#issuecomment-357162384

0
votes

Just had the same problem with cordova 8.0 and android 7.0

Workaround is to update fcm_config_files_process.js in the plugin folder. Make the following changes:

  • Replace "platforms/android/res/values/strings.xml" with "platforms/android/app/src/main/res/values/strings.xml"

  • Replace "platforms/android/google-services.json" with "platforms/android/app/google-services.json"

Like others have said, the problem is that directory paths have changed. But it's not difficult to just update them in that js file. I'm surprised they haven't fixed this by now.