0
votes

After adding Youtube-video-player plugin to my project build is getting failed saying:

Parsing platforms/android/res/xml/config.xml failed

(node:6525) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'platforms/android/AndroidManifest.xml' at Object.fs.openSync (fs.js:663:18) at Object.fs.readFileSync (fs.js:568:33) at Object.parseElementtreeSync (platforms/android/cordova/node_modules/cordova-common/src/util/xml-helpers.js:180:27) at new AndroidManifest (platforms/android/cordova/lib/AndroidManifest.js:29:20) at updateProjectAccordingTo (platforms/android/cordova/lib/prepare.js:187:20) at platforms/android/cordova/lib/prepare.js:47:16 at _fulfilled (platforms/android/cordova/node_modules/q/q.js:854:54) at self.promiseDispatch.done (platforms/android/cordova/node_modules/q/q.js:883:30) at Promise.promise.promiseDispatch (platforms/android/cordova/node_modules/q/q.js:816:13) at platforms/android/cordova/node_modules/q/q.js:570:49 (node:6525) 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:6525) [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.

3

3 Answers

1
votes

If you are using Cordova version 7.0.0 or later then downgrade to cordova version 6.5.0 for the plugin to work. Directory structure created by latest version is different than the older one and the plugin has not been updated accordingly to accommodate it and that's why you get this error. After downgrading remove and add the Android Platform again and also remove other plugins as they may not work with the older version and add them again in your project

0
votes

Most of the times these problems are solved by removing the platform and then adding it again cleanly.

To remove the Android platform

ionic cordova platform remove android

Before adding it again, chack that you YouTube API key is present in config.xml

<preference name="YouTubeDataApiKey" value="[YOUR YOUTUBE API]" />

Add it if you need to then add the Android platform:

ionic cordova platform add android
0
votes

Un-Install old plugins npm uninstall @ionic-native/youtube-video-player and install the latest plugin npm install --save @ionic-native/youtube-video-player@4