feiyangbaxia 2015-01-09
<?xml version="1.0" ?> <project name ="antPro" default ="sign" basedir ="E:/anttest"> <property environment="env" /> <property name="jarsigner" value="${env.JAVA_HOME}/bin/jarsigner.exe" /> <property name="apkdir" value="E:/anttest" /> <property name="apkname" value="hello" /> <property name="apkworkdir" value="${apkdir}/${apkname}" /> <path id="dex2jar_classpath"> <fileset dir="E:/anttest/dex2jar/"> <include name="*.jar"/> </fileset> </path> <!-- <path id="apktool_classpath"> <fileset dir="${basedir}/"> <include name="apktool.jar"/> </fileset> </path> <target name="deapk"> <java classname="brut.apktool.Main" classpathref="apktool_classpath"> <arg value="d"/> <arg value="E:/anttest/hello.apk"/> <arg value="E:/anttest/hello"/> </java> </target> <target name="enapk"> <java classname="brut.apktool.Main" classpathref="apktool_classpath"> <arg value="b"/> <arg value="E:/anttest/hello.apk"/> <arg value="E:/anttest/hello"/> </java> </target> --> <target name="unapk"> <unzip src="${apkdir}/hello.apk" dest="${apkdir}/${apkname}"/> </target> <target name="dex2jar" depends="unapk"> <java classname="com.googlecode.dex2jar.v3.Main" classpathref="dex2jar_classpath"> <arg value="E:/anttest/hello/classes.dex"/> </java> </target> <target name="jar2class" depends="dex2jar"> <unzip src="${apkworkdir}/classes_dex2jar.jar" dest="${apkworkdir}/classes_dex2jar"/> <delete file="${apkworkdir}/classes.dex"/> <copy file="E:/anttest/Hello.class" tofile="${apkworkdir}/classes_dex2jar/com/test/Hello.class"/> </target> <!-- <target name="class2jar"> <zip basedir="E:/anttest/hello/classes_dex2jar" zipfile="E:/anttest/hello/classes_dex2jar_ok.jar"/> </target> --> <target name="class2dex" depends="jar2class"> <java classname="com.googlecode.dex2jar.tools.Jar2Dex" classpathref="dex2jar_classpath"> <arg value="-f"/> <arg value="-o"/> <arg value="${apkworkdir}/classes.dex"/> <arg value="${apkworkdir}/classes_dex2jar"/> </java> </target> <target name="apk" depends="class2dex"> <delete file="${apkworkdir}/classes_dex2jar.jar"/> <delete dir="${apkworkdir}/classes_dex2jar"/> <delete includeemptydirs="true"> <fileset dir="${apkworkdir}/META-INF" includes="**/*"/> </delete> <zip basedir="${apkworkdir}" zipfile="${apkdir}/hello2.apk"/> </target> <target name="sign" depends="apk"> <exec executable="${jarsigner}" failonerror="true"> <arg value="-verbose" /> <arg value="-storepass" /> <arg value="3270135" /> <arg value="-keypass" /> <arg value="3270135" /> <arg value="-keystore" /> <arg value="mykeystore.keystore" /> <arg value="-signedjar" /> <arg value="${apkdir}\hello2_sign.apk" /> <arg value="${apkdir}\hello2.apk" /> <arg value="mykeystore" /> </exec> </target> </project>