ionic build android's Error : copyFileSync: could not write to dest file

mehdigriche picture mehdigriche · Dec 28, 2017 · Viewed 28.9k times · Source

When I use the command : ionic cordova build android here is what I get :

cp: copyFileSync: could not write to dest file (code=ENOENT):/Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml

Parsing /Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml failed (node:2306) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml'

[10:50:14] lint finished i

Answer

dtmp picture dtmp · Apr 11, 2018

Add this hook to cordova project: patch-android-studio-check.js

  1. Put the file patch-android-studio-check.js in the directory hooks of your project

  2. Add the following lines to the config.xml of your project:

    <platform name="android">
        <hook src="hooks/patch-android-studio-check.js" type="before_plugin_install" />
        <hook src="hooks/patch-android-studio-check.js" type="before_plugin_add" />
        <hook src="hooks/patch-android-studio-check.js" type="before_build" />
        <hook src="hooks/patch-android-studio-check.js" type="before_run" />
        <hook src="hooks/patch-android-studio-check.js" type="before_plugin_rm" />
    </platform>
    
  3. Delete the plugins directory:

    rm -rf plugins
    
  4. Reinstall the plugins:

    ionic build
    
  5. Reinstall the platform android:

    cordova platform rm android
    cordova platform add android@latest