Ant构建AAPT紧缩剥离draw9从图书馆资源的图像信息 [英] Ant Build AAPT Crunch is stripping draw9 information from Library resource images

查看:240
本文介绍了Ant构建AAPT紧缩剥离draw9从图书馆资源的图像信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用的库项目一期工程。图书馆计划有draw9(9.png)文件,并通过Ant构建APK当它被剥离在可扩展和可填写领域draw9信息。其结果是,该应用只是拉伸图像,而不使用draw9信息。 在Android中的build.xml

I have a project that is using a library project. The Library Project has draw9 (9.png) files and when building the apk via Ant it is stripping the draw9 info on scaleable and fillable areas. The result is that the app just stretches the images without using draw9 info. In Android's build.xml

 <target name="-package-resources" depends="-crunch">

这是调用紧缩,从而更新pre-处理PNG缓存(任何人都知道这个缓存举行?)。

this is calling crunch, which updates the pre-processed PNG cache (anyone know where this cache is held?).

-crunch运行在AAPT称为紧缩的任务。但我一直没能找到有关参数的任何信息。这似乎是从RES文件夹取文件,并把它在出RES文件夹(默认斌/ RES)。

-crunch runs a task in aapt called crunch. But I have not been able to find any information on the arguments. It seems to be taking files from the Res folder and putting it in the out res folder (by default bin/res).

所以,我甚至清除的任务,所以它不会跑紧缩,仍然图像无法正常伸展。然后,我与PNG文件的直接复制到了RES文件夹,还是同样的问题取代了它。我甚至尝试蚂蚁清洁这些任务之间,我得到了同样的问题。这使我相信在缓存被关押在项目区外,但在哪里?

So I even cleared the task so it would not run crunch, and still images weren't stretched properly. I then replaced it with a straight copying of the png files to the out res folder, and still same issue. I even tried ant clean in between these tasks and I got the same problem. Which leads me to believe the cache is being held outside the project area, but where?

请注意,当我用Eclipse构建这一切都很好。

Note when I build it with Eclipse all is fine.

这对我的作品的另一个解决方案是将这些图像从图书馆到主项目复制,但它不是理想的解决方案。

The other solution that works for me is to copy these images from the Library into the Main Project, but it's not the ideal solution.

其他人似乎有与此<一个问题href="http://stackoverflow.com/questions/12970438/crunch-resource-packaging-with-aapt-in-ant-build-uses-cache-from-other-projects">crunch/resource包装与AAPT在Ant构建使用来自其他项目的缓存

在他们提到有关缓存 bug报告一>只使用时间戳来检查是否更新缓存或不

In this bug report they mention about the cache only using timestamps to check whether to update the cache or not.

这似乎是源$ C $下AAPT ,但我遇到了麻烦试图寻找到这个缓存读取它举行。

This seems to be the source code for aapt, but I had trouble trying to find where this cache is held from reading it.

找出问题

有关我是什么原因导致的问题是,我用不同的文件夹(故意)的蚂蚁为我资源,src和仓。有一个refernce project.library.res.folder.path 这得到填补的依赖宏。它指向默认资源,以及从项目文件夹仓。所以,我所做的是改变它们指向我的新文件夹。但在这样做,我是不断变化的,他们列出的旧的。它启动了资源文件混合成不同的库项目时,AAPT是正在运行的我用。当我固定的顺序是编译好的。我还没有为它project.library.bin.r.file.path。

For me what was causing the problem was that I was using different folders (intentionally) in Ant for my res, src and bin. There is a refernce project.library.res.folder.path which gets filled in dependency macro. It points to the default res, and bin folders from the project. So what I did was to change them to point my new folders. But in doing that I was changing the older they were listed. It started mixing up the resource files into different library project I was using when aapt was being run. When I fixed the order it was compiling fine. I also did it for project.library.bin.r.file.path.

推荐答案

我有完全相同的问题昨天。

I've had exactly the same problem yesterday.

我有一个codeBase的,我用用Ant来构建应用程序的不同口味(差异包名称和一些特定的资源)。

I have one codebase which I use to build different flavours of the app (diff package-name and some specific resources) using ant.

build.xml文件工作得很好,但9patches被同时使用的应用程序损坏(如你所说,作为PNG和拉伸)。

build.xml worked fine but 9patches were corrupted while using app (as you say, treated as png and stretched).

我明确了这个问题,以在 -crunch 任务蚂蚁(就像你)。

I nailed down the problem to -crunch task within ant (just as you did).

在我来说,我使用两种不同的 RES 文件夹,所以我改变了原来的紧缩任务,从这个

In my case I use two different res folders so I changed original crunch task from this

<!-- Updates the pre-processed PNG cache -->
    <target name="-crunch">
        <exec executable="${aapt}" taskName="crunch">
            <arg value="crunch" />
            <arg value="-v" />
        <arg value="-S" />
            <arg path="${resource.absolute.dir}" />
            <arg value="-C" />
            <arg path="${out.res.absolute.dir}" />
        </exec>
    </target>

 <target name="-crunch">
        <exec executable="${aapt}" taskName="crunch">
            <arg value="crunch" />
            <arg value="-v" />
            <arg value="-S" />
            <arg path="${resource.flavour.dir}" />
            <arg value="-S" />
            <arg path="${resource.absolute.dir}" />
            <arg value="-C" />
            <arg path="${out.res.absolute.dir}" />
        </exec>
    </target>

但由此产生提到9patch文物(也喜欢FB库)..所以我想我会改变这个处理 resourceflavour.dir 只有当这是不是图书馆这给了正确的结果(无9pathc文物)

but this produced mentioned 9patch artefacts (also in libraries like fb) .. so I thought I will change this to process resourceflavour.dir only if this is not a library which gave proper result (no 9pathc artefacts)

<target name="-crunch">
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <exec executable="${aapt}" taskName="crunch">
            <arg value="crunch" />
            <arg value="-v" />
            <arg value="-S" />
            <arg path="${resource.flavour.dir}" />
            <arg value="-C" />
            <arg path="${out.res.absolute.dir}" />
        </exec>
    </do-only-if-not-library>
        <exec executable="${aapt}" taskName="crunch">
            <arg value="crunch" />
            <arg value="-v" />
            <arg value="-S" />
            <arg path="${resource.absolute.dir}" />
            <arg value="-C" />
            <arg path="${out.res.absolute.dir}" />
        </exec>
</target>

这可能给你一个线索,以妥善解决你的情况。

This might give you a clue to proper solution in your case.

这篇关于Ant构建AAPT紧缩剥离draw9从图书馆资源的图像信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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