为什么Android的AAPT除去资产.gz的文件扩展名? [英] Why does Android aapt remove .gz file extension of assets?

查看:277
本文介绍了为什么Android的AAPT除去资产.gz的文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我添加一个GZIP-ED文件到我的Andr​​oid项目的资产,该项目将打包的时候。广州扩展名被剥离。 (所以,举例来说,foo.gz在我的资产文件夹需要使用 getAssets()在code进行访问。打开(富))。这似乎并不与其他扩展名(例如,。html的),我使用的情况发生。资产仍然是GZIP-ED(我来包装输入流中的GZIPInputStream读它)。

When I add a GZIP-ed file to my Android project's assets, the ".gz" extension is stripped when the project is packaged. (So, for instance, "foo.gz" in my assets folder needs to be accessed in code using getAssets().open("foo").) This doesn't seem to happen with other extensions (e.g., ".html") that I'm using. The asset is still GZIP-ed (I have to wrap the input stream in a GZIPInputStream to read it).

这是标准的行为或错误?如果它是标准的,有哪些扩展被剥离的任何文档,哪些是preserved?

Is this standard behavior or a bug? If it's standard, is there any documentation about which extensions are stripped and which are preserved?

编辑:我说错东西悦目。我遇到这个问题与Eclipse插件。我没有试过直接运行AAPT,看看问题是否与工具本身或插件是如何使用它。

I misstated things sightly. I'm experiencing this problem with the Eclipse plug-in. I haven't tried running aapt directly to see if the problem is with the tool itself or with how the plug-in is using it.

推荐答案

下面我该如何解决这个问题,只是在做勾构建前科尔多瓦。
https://gist.github.com/josx/fc76006e6d877b17fefd

Here How i solve it, just doing a cordova before build hook. 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);

这篇关于为什么Android的AAPT除去资产.gz的文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆