Packing and repacking an APK file

I’m creating a software using AIR that will guide the user through a few steps, to publish an android application (APK file).

The way I am doing this, is that the APK file is already compiled, and all I need to do is replace an XML file in the package, and that will change the behaviour of the application. My big problem now, is that unpacking the apk file, and doing any tiny text edit, and then packing it again, breaks the signature and prevents the application from running on any device, giving a message that the signature is incorrect.

How can I solve this? I want to safely open the APK, write something in a text file, and close it again. Note that this operation will be done on the user’s computer (after he purchases our application) so we’re look for a command-line tool with no special requirements like JDK.

Any help?