当我将 GZIP 压缩文件添加到 Android 项目的资源中时,打包项目时“.gz”扩展名将被删除。 (因此,例如,我的资产文件夹中的“foo.gz”需要在代码中使用getAssets().open("foo")
.)我使用的其他扩展名(例如“.html”)似乎不会发生这种情况。该资源仍然是 GZIP 编码的(我必须将输入流包装在 GZIPInputStream 中才能读取它)。
这是标准行为还是错误?如果它是标准的,是否有任何关于删除哪些扩展以及保留哪些扩展的文档?
编辑:我明显错误地陈述了事情。我在使用 Eclipse 插件时遇到了这个问题。我还没有尝试直接运行 aapt 来查看问题是否出在该工具本身或插件如何使用它。
这里我如何解决它,只需在构建钩子之前做一个科尔多瓦。https://gist.github.com/josx/fc76006e6d877b17fefd https://gist.github.com/josx/fc76006e6d877b17fefd
#!/usr/bin/env node
/**
* Lets clean up some files that conflicts with aapt.
* https://osvaldojiang.com/p/137
* https://github.com/driftyco/ionic/issues/4584
* http://stackoverflow.com/questions/4666098/why-does-android-aapt-remove-gz-file-extension-of-assets
* https://forum.ionicframework.com/t/android-build-failed-ionic-cordova-unable-to-add-asset-file-file-already-in-archive/41146
*/
var glob = require('glob');
var fs = require('fs');
var path = require('path');
var deleteFilesFromFolder = function(globExp) {
// Find files
glob(globExp, function(err,files) {
if (err) throw err;
files.forEach(function(item, index,array) {
console.log(item + " found");
});
// Delete files
files.forEach(function(item, index,array) {
fs.unlink(item, function(err) {
if (err) throw err;
console.log(item + " deleted");
});
});
});
};
var globExp = path.resolve(__dirname, '../../www/lib') + '/**/*.gz';
deleteFilesFromFolder(globExp);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)