ionic build android's Error : copyFileSync: could not write to dest file
ionic build android's Error : copyFileSync: could not write to dest file
When I use the command : ionic cordova build android
here is what I get :
ionic cordova build android
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
8 Answers
8
Add this hook to cordova project: patch-android-studio-check.js
Put the file patch-android-studio-check.js in the directory hooks of your project
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>
<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>
Delete the plugins directory:
rm -rf plugins
rm -rf plugins
Reinstall the platform android:
cordova platform rm android
cordova platform rm android
cordova platform add android@latest
cordova platform add android@latest
Your command: ionic cordova build androird is wrong
I think you means: ionic cordova build android
But try also: ionic cordova build --release android
I had the same error, after 2 days of debugging I found a solution for me:
in the directory: platforms/android/cordova
I updated in the file Api.js the locations object, because the path are not correct.
current locations object look like this in my Api.js:
this.locations = {
root: self.root,
www: path.join(self.root, 'assets/www'),
res: path.join(self.root, 'res'),
platformWww: path.join(self.root, 'platform_www'),
configXml: path.join(self.root, 'app/src/main/res/xml/config.xml'),
defaultConfigXml: path.join(self.root, 'cordova/defaults.xml'),
strings: path.join(self.root, 'app/src/main/res/values/strings.xml'),
manifest: path.join(self.root, 'app/src/main/AndroidManifest.xml'),
build: path.join(self.root, 'build'),
javaSrc: path.join(self.root, 'app/src/main/java/'),
// NOTE: Due to platformApi spec we need to return relative paths here
cordovaJs: 'bin/templates/project/assets/www/cordova.js',
cordovaJsSrc: 'cordova-js-src'
};
After these change I was able to build my app.
I had also errors because of plugins like cordova-sqlite-storage so I removed it and build the app.
I hope it helps
i've tried that but with no success sorry to not mention that everything was ok when i build with ionic 1 everything goes well but when i use ionic 3 it gives me this also this problem is in the platforms folder when i use another folder from an ionic 1 project it fixed
– mehdigriche
Dec 29 '17 at 16:48
Golden-Star-Solution!
– Gary Klasen
May 7 at 9:16
To solve this problem
cp: copyFileSync: could not write to dest file
(code=ENOENT):/Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml
Create a folder named xml
in platforms/android/res
xml
platforms/android/res
I have faced the same issue this morning and my (rather drastic) solution was this:
ionic cordova platform rm android
platforms
plugins
www
npm install
ionic cordova platform add android
ionic cordova build android
I would keep the "www" folder when you're doing this reset! You may have important asset files in there. :)
– xke
Mar 12 at 4:48
They already present in src folder so no need to worry about that although deleting www will not have any effect @xke
– Black Mamba
Apr 8 at 16:58
That depends on your Ionic version - for Ionic v1 projects, you shouldn't delete the 'www' folder!
– kolli
Jun 8 at 16:50
Thanx Worked For Me
– Praveen Vishnu
yesterday
Note on dtmp's Answer, using the hooks directory seems to be deprecated. Using 'scripts' directory instead might be more appropriate.
When trying to make a build using ionic 2, using a 'hooks' directory lead to the hook js not being found.
Assuming the
Androird
part is just a typo here.
Check this out:
https://github.com/ionic-team/ionic/issues/13702
It is a known issue and not fixed yet!
Apparently, some files are not generated correctly when adding android +7 so, I solved this problem by the following:
Firstly remove your platform,
ionic cordova platform rm android
then reinstall a lower version (6.3 worked for me )
ionic cordova platform add android@6.3.0
can you add more information about solution?
– Vivek
Jun 25 at 19:22
@Vivek Android 7+ broke a lot of things, so it's easier to roll back to 6.4.0 for now if your pressed for time and can't find alternative plugins.
– Trevor D
Jun 28 at 20:10
If you are like me trying to overcome same issue and try all the way written as solution but not. Try this solution;
project.json
"android-versions" : "1.3.0"
sudo ionic cordova run android
Happy coding!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you checked the existence of or the permissions on the files mentioned in the error?
– Thomas Smyth
Dec 28 '17 at 11:17