我正在使用凉亭来下载和管理所有聚合物组件。但是,添加“bower_components”文件夹后,Cordova无法再成功构建。
: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
好像是因为/ web-animations-js中的.gz文件。
无论如何,还有很多文件和文件夹应该被删除,例如那些“测试”和“演示”文件夹,当我下载带有凉亭的组件时,它包括在内。
我该如何解决这个问题?
答案 0 :(得分:4)
我删除了你提到的.gz文件并让它运行起来。我不确定完整的解决方案是什么。
答案 1 :(得分:2)
我不确定为什么Cordova的构建失败,但回答关于删除测试/演示文件的第二个问题,您可以使用Cordova hooks。
我们在Cordova之上使用Ionic Framework,并且有一篇关于Cordova钩子的文章here。
因此,我们使用的一个钩子是位于030_clean_dev_files_from_platforms.js
目录中的名为hooks/after_prepare
的文件,其中包含以下内容:
#!/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);