I've had exactly the same problem yesterday.
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 worked fine but 9patches were corrupted while using app (as you say, treated as png and stretched).
I nailed down the problem to -crunch
task within ant (just as you did).
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>
to this
<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>
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.