ant签名zipaligh

build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Peter's ApkSigner" default="zipalign">

<property name="projectname" value="OliveBrowser2"/>
<property name="sdk.dir" value="D:\\GreenSoft\\android-sdk-windows"/>
<property name="zipalign" value="${sdk.dir}\\tools\\zipalign.exe"/>
<property name="apkdir" value="."/>
<property name="unsignedapkname" value="${projectname}.apk"/>
<property name="signedapkname" value="${projectname}-signed.apk"/>
<property name="zipedapkname" value="${projectname}-signed-ziped.apk"/>
<property name="keystore" value="E:\\MyDocument\\OliveBrowser\\key\\olivebrowser.keystore"/>
<property name="alias" value="olivebrowser"/>
<property name="storepass" value="xx00xx00"/>
<property name="keypass" value="${storepass}"/>
<property name="verbose" value="-verbose"/>

<target name="jarsigner" >
	<echo>starting signAPK ${apkdir}//${unsignedapkname} ...</echo>
	<signjar
		jar="${apkdir}/${unsignedapkname}"
		signedjar="${apkdir}/${signedapkname}"
		keystore="${keystore}"
		storepass="${storepass}"
		alias="${alias}"
		keypass="${keypass}"
		verbose="${verbose}" />
</target>

<target name="zipalign" depends="jarsigner">
	<echo>starting zipalign ${apkdir}//${signedapkname}...</echo>
	<exec executable="${zipalign}" failonerror="true">
		<arg value="-v" />
		<arg value="-f" />
		<arg value="4" />
		<arg value="${apkdir}/${signedapkname}" />
		<arg value="${apkdir}/${zipedapkname}" />
	</exec>
</target>

</project>
 

 

 唯一需要修改的就是projectname和sdk.dir,

将apk放在build.xml同目录下,执行ant即可。

你可能感兴趣的:(ant)