Reputation: 94319
I'm using bower to download and manage all the polymer components. However after adding the "bower_components" folder, Cordova can no longer build successfully.
:processDebugResources Unable to add 'C:\...\platforms\android\build\intermediates\assets\debug\www\bower_components\web-animations-js\web-animations.min.js.gz': file already in archive (try '-u'?) ERROR: unable to process assets while packaging 'C:\...\platforms\android\build\intermediates\res\resources-debug.ap_' ERROR: packaging of 'C:\...\platforms\android\build\intermediates\res\resources-debug.ap_' failed :processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':processDebugResources'. ....... Error Code: 1 Output: Unable to add 'C:\...\platforms\android\build\intermediates\assets\debug\www\bower_components\web-animations-js\web-animations.min.js.gz': file already in archive (try '-u'?) ERROR: unable to process assets while packaging 'C:\...\platforms\android\build\intermediates\res\resources-debug.ap_' ERROR: packaging of 'C:\...\platforms\android\build\intermediates\res\resources-debug.ap_' failed * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 13.038 secs
It seems like it's because of the .gz file in /web-animations-js.
Anyway, there are also a lot of files and folders that should be removed, such as those "test" and "demo" folders, which is included when I download the components with bower.
How should I solve this problem?
Upvotes: 10
Views: 892
Reputation: 41
I deleted the .gz file you mentioned and got it to work. I'm not exactly sure what the complete solution is.
Upvotes: 4
Reputation: 4739
I am not sure why the build of Cordova is failing, but answering your second question regarding the removal of test/demo files, you could make use of the Cordova hooks.
We are using Ionic Framework on top of Cordova and there is a interesting article here about some Cordova hooks.
So one of the hooks we are using is a file called 030_clean_dev_files_from_platforms.js
located in the hooks/after_prepare
directory and contains the following:
#!/usr/bin/env node
/**
* After prepare, files are copied to the platforms/ios and platforms/android folders.
* Lets clean up some of those files that arent needed with this hook.
*/
var fs = require('fs');
var path = require('path');
var deleteFolderRecursive = function(removePath) {
if( fs.existsSync(removePath) ) {
fs.readdirSync(removePath).forEach(function(file,index){
var curPath = path.join(removePath, file);
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(removePath);
}
};
var iosPlatformsDir_1 = path.resolve(__dirname, '../../platforms/ios/www/css');
var iosPlatformsDir_2 = path.resolve(__dirname, '../../platforms/ios/www/app');
var iosPlatformsDir_3 = path.resolve(__dirname, '../../platforms/ios/www/dist/dist_js/app');
var androidPlatformsDir_1 = path.resolve(__dirname, '../../platforms/android/assets/www/css');
var androidPlatformsDir_2 = path.resolve(__dirname, '../../platforms/android/assets/www/app');
var androidPlatformsDir_3 = path.resolve(__dirname, '../../platforms/android/assets/www/dist/dist_js/app');
var browserPlatformsDir_1 = path.resolve(__dirname, '../../platforms/browser/www/css');
var browserPlatformsDir_2 = path.resolve(__dirname, '../../platforms/browser/www/app');
var browserPlatformsDir_3 = path.resolve(__dirname, '../../platforms/browser/www/dist/dist_js/app');
deleteFolderRecursive(iosPlatformsDir_1);
deleteFolderRecursive(iosPlatformsDir_2);
deleteFolderRecursive(iosPlatformsDir_3);
deleteFolderRecursive(androidPlatformsDir_1);
deleteFolderRecursive(androidPlatformsDir_2);
deleteFolderRecursive(androidPlatformsDir_3);
deleteFolderRecursive(browserPlatformsDir_1);
deleteFolderRecursive(browserPlatformsDir_2);
deleteFolderRecursive(browserPlatformsDir_3);
Upvotes: 2