android混淆build.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project name=".Test" default="debug-obf">
	<!-- Echo the Java JDK version. 
		If needed, link /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK to 1.6 -->
	<echo message="ant is using Java sdk ${ant.java.version}" />

	<!-- Some properties. Change paths as needed -->
	<property name="JAVA_HOME" value="C:\Program Files\Java\jdk1.6.0_10\bin" />
	<property name="sdk-location" value="E:/android-sdk-windows" />
	<property name="sdk-folder" value="E:/android-sdk-windows" />
	<property name="proguard-home" value="E:/android-sdk-windows/proguard4.5.1/lib" />
	<property name="proguard-jar" value="E:/android-sdk-windows/proguard4.5.1/lib" />
	<property name="outdir" value="bin" />
	<property name="outdir-classes" value="${outdir}/classes" />
	<property name="library-jar" value="libs" />
	<property name="android-jar" value="${sdk-folder}/platforms/android-3/android.jar" />

	<echo>${java.home}</echo>

	<!-- Template from command 'android create project' 
		Uses: ${sdk-folder}/platforms/android-1.5/templates/android_rules.xml -->
	<property file="local.properties" />
	<property file="build.properties" />
	<property file="default.properties" />

	<path id="android.antlibs">
		<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
		<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
		<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
		<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
		<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
	</path>

	<taskdef name="setup" classname="com.android.ant.SetupTask" classpathref="android.antlibs" />

	<setup />
	<setup />

	<!-- Package the application and sign it with a debug key, with obfuscation
	         This is the default target when building. It is used for debug. -->
	<target name="debug-obf" depends="dex-obf, package-resources">
		<apkbuilder outfolder="${out-folder}" basename="${ant.project.name}" signed="true" verbose="false">
			<file path="${intermediate-dex}" />
			<sourcefolder path="${source-folder}" />
			<jarfolder path="${external-libs-folder}" />
			<nativefolder path="${native-libs-folder}" />
		</apkbuilder>
	</target>


	<!-- Package the application without signing it, with obfuscation
	         This allows for the application to be signed later with an official publishing key. -->
	<target name="release-obf" depends="dex-obf, package-resources">
		<apkbuilder outfolder="${out-folder}" basename="${ant.project.name}" signed="false" verbose="false">
			<file path="${intermediate-dex}" />
			<sourcefolder path="${source-folder}" />
			<jarfolder path="${external-libs-folder}" />
			<nativefolder path="${native-libs-folder}" />
		</apkbuilder>
		<echo>All generated packages need to be signed with jarsigner before they are published.</echo>
	</target>


	<!-- Using proguard for the actual obfuscation. 
			Referenced from: http://code.google.com/p/zxing/source/browse/trunk/android-m3/build.xml?r=321 -->
	<target name="optimize" depends="compile">
		<jar basedir="${outdir-classes}" destfile="temp.jar" />
		<java jar="${proguard-home}/proguard.jar" fork="true" failonerror="true">
			<jvmarg value="-Dmaximum.inlined.code.length=32" />
			<arg value="-injars temp.jar" />
			<arg value="-outjars optimized.jar" />
			<arg value="-libraryjars ${android-jar}" />
			<!-- <arg value="-libraryjars ${library-jar}/some_lib_used.jar"/> -->
			<arg value="-dontpreverify" />
			<arg value="-dontoptimize" />
			<arg value="-dontusemixedcaseclassnames" />
			<arg value="-repackageclasses ''" />
			<arg value="-allowaccessmodification" />
			<arg value="-keep public class com.demo.Test" />
			<!-- <arg value="-keep public class com.just2me.obfapp.receiver.*"/> -->
			<arg value="-optimizationpasses 1" />
			<arg value="-verbose" />
			<arg value="-dontskipnonpubliclibraryclasses" />
			<arg value="-dontskipnonpubliclibraryclassmembers" />
		</java>
		<delete file="temp.jar" />
		<delete dir="${outdir-classes}" />
		<mkdir dir="${outdir-classes}" />
		<unzip src="optimized.jar" dest="${outdir-classes}" />
		<delete file="optimized.jar" />
	</target>


	<!-- Convert into .dex -->
	<target name="dex-obf" depends="compile, optimize">
		<echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
		<apply executable="${dx}" failonerror="true" parallel="true">
			<arg value="--dex" />
			<arg value="--output=${intermediate-dex-location}" />
			<arg path="${out-classes-location}" />
			<fileset dir="${external-libs-folder}" includes="*.jar" />
		</apply>
	</target>

	<!-- Cleaning up the house -->
	<target name="clean">
		<delete dir="${outdir}" />
	</target>
</project>
 

你可能感兴趣的:(android,windows,xml,ant,Google)