美高梅娱乐4858.comandroid自动包方法(ant+proguard+签名)

                </proguard>

前不久浏览了一晃境内比较好之几乎单视频网站,发现以电击排行榜及名列前矛的都是于在黄色擦边球的录象,可以说,发布这些情节之逐条都是市面专家。能够准确的把握消费正的思,合理的让自己的成品定位。
再就是因为同视频网站合作的法门也能致富到部分入账,这些行为简直是出色之投资。
视频网站,自去年张玉宣布录象以来,就从头当国内互联网上起了,目前曾闹几颇品牌。目前,国内又冒出了同过去底
个人网站热,BBS热,门户热,BLOG热
一样的视频热,很多视频网站要狼烟一样四由,试图在网上分割天下。互联网的竞争比传统行业越来越残酷,因为提供的服务大为难定量,定性,连克寻找一搜索的活还不曾,都是于流量达同样断高低。甚至多流量异常高之网络服务却招来不至盈利模式,这一点凡致命的,开商店,不是打慈善,即使抓慈善呢得有支持!视频网站也如此,
眼下的互联网,除了电信等网络接入商能够长期发展,其他的不都是几乎年河东,几年河西。我们上网除了要掏网费,还有那多的要求使那些网站去满足呢?互联网的创收,几乎离不起来广告费是事物,包括大家也底感慨的GOOGLEEATH也是这样。网络游戏倒是个不同,它的虚拟产品能当实物一样出售,哪个游戏的刀子都于你以杂货铺选购的王麻子刀要昂贵多加倍,这是怎呢?我们好谈谈以下最底部的事物,那便是:目前存在在简单个世界,一个是有大街,有阳光,有战争,有好,有性的真正世界,一个凡坐互联网也沟通,以服务器,PC等做的虚构世界。这半单之关联是:现实世界得以孤立存在,可以免欲网络(您会说,那怎么行,那多滑坡啊“`可人类已落伍了几百万年了),而目前的虚构世界又凭和具体世界,你说一个服务器被任何一个服务器一些电子货币有啊含义?最终要不更换成为现实货币,它有啊价,虽然里可以抵消帐项(这同一触及老轻吃人口误解,这便是电子货币的价,其实没物质的置换,我们的钞票还是借的“`),但是它们只是我们物质需要的一样栽载体。
咱们更探GOOGLEEath这个东西,GOOGLE的前途就是扣留它了,什么山头,BBS,BLOG,电子商务,它们还做呀吧?从不过底部的拘留,都是在法现实世界罢了,所以当互联网是行当,谁模仿的越像,谁就是是死,你达到BBS,BLOG充其量,也是拿温馨的日记本复制了瞬间,搞到网上去矣(而且连友好的好坏书法都没法展示),更进一步,有看齐频网了,你可以录象,自拍(不乏友好做贱自己之情节),把团结看见的,想说的且能够理届网上去矣!可是这些还是比不了网络游戏,你可天天当网上换换衣裳,不随便电脑桌上有没产生度,游戏里之若得先行喝相同人,望游戏止干也,正像大多数转悠戏迷(没有沉溺的莫到底)玩游戏的目的一样:找到了一个于现实生活更有增无减的地方。最终网络游戏的效应是:游戏奴隶们将那个把的钱撒到玩之中,其实是散落至了打运营商的虚构帐户里面,然后他们而把钱得下,买买毫宅等消费有,还好继承向游戏中投资,包括宣传,开新地图,开新区等等,总之如同现实社会同资金循环起来了,它不是概括的大循环,而是滚雪球般每届一个地方便重糊一些上。所以大家看,搞娱乐的充分赚钱,但是就尚是不足够眩,因为网络在此时此刻的技术水平下还是匪能够离开实际社会的,你玩游戏得起钱呀(不要点卡的比要点卡的还越轨),所以您只要以耍里赚钱几乎很为难,因为非常为难形成差价交易,就似乎你想在LIKE的专卖店下面在开2级代理,还想赚一样难,游戏里面没运费,没有商品信息价值的套,而且他最终使转会成人民币,这还设大家拿玩网游赚钱是题材没办法。网游只发生一个得主,是运营商!所以在”面向群众“
这个题目及,游戏做的不够成功!出了GOOGLEEATH以后,就易了一些,它看明白了最底部的事物:互联网要效法世界,只要把握这个要就足以最终成为这领域的霸主,游戏就是于那些(曾经包括自)傻子设计之,而GOOGLEEATH却会在编造世界被满足大多数口的需。我们之所以互联网只是是拉现实世界的一致种植手段,不是还得仰仗它,甚至离开不开它!您想买商品,我们一般还是预先在网上查,去只能了解它的:外观与口碑,仅次2桩,质感,重量,气味等很多咱们还无法实现人机模拟,充其量就是一致段落发生广告嫌疑的视频。真正使置还得盼实物,至于网络购,只是发货地和付法,运输方式各异而已。我敢说于GOOGLEEATH推出3D效仿的时刻,他的总裁并无敢妄想人们从此会拄网络实现旅行来放松自己,它冲其量也是为众人尝尝鲜,先去虚拟的浏览一下,必定电子计算机和现实世界被之这些化学计算机于起来还要落后不知道多少亿只水平!正而黑客帝国一样,即使计算机统治了举世,还是发生只西岸存在!

 

<property name=”zipalign”
location=”${android.tools.dir}/zipalign${exe}” />

<!– Verbosity –>

<sequential>

 

<target name=”-set-debug-mode” depends=”-debug-obfuscation-check”>

                        –>

 

                   We actually store build.packaging.debug, not
build.release –>

<arg value=”-r” />

<mkdir dir=”${out.dir}/out/class” />

 

<!–

<property name=”resource.package.file.name”
value=”${ant.project.name}.ap_” />

<property name=”key.alias.password” value=”xxxx” />

 

              libraries –>

                     check if the property set in
-debug/release-obfuscation-check is set to true.

<input message=”Please enter password for alias ‘${key.alias}’:”
addproperty=”key.alias.password” defaultvalue=”5201314..” />

<if condition=”${manifest.hasCode}”>

</aapt>

<nativefolder refid=”project.libraries.libs” />

<!– 原来的类似公事,使用Bin/classes下的–>

<target name=”-package-release” depends=”-dex,
-package-resources”>

</target>

<xpath input=”AndroidManifest.xml”
expression=”/manifest/application/@android:hasCode”
output=”manifest.hasCode” default=”true” />

<property name=”asset.absolute.dir” location=”${asset.dir}” />

<property file=”default.properties” />

<property name=”build.signing.debug” value=”true” />

<and>

              The property ‘verbosity’ is not user configurable and
depends exclusively on ‘verbose’

<property name=”out.classes.absolute.dir”
location=”${out.classes.dir}” />

                     ** Make sure unless=”do.not.compile” is used in
the target definition **

<echo>*************************************************</echo>

 

</classpath>

<arg value=”-repackageclasses” />

                   when using Ant before 1.8 –>

<element name=”external-libs” optional=”yes” />

<pathelement location=”${emma.dir}/emma_ant.jar” />

<else>

<property name=”android.libraryjars” refid=”android.target.classpath”
/>

<arg value=”-keep public class * extends android.app.Activity” />

<exec executable=”${zipalign}” failonerror=”true”>

<pathelement location=”${emma.dir}/emma.jar” />

 

<arg value=”-libraryjars ${android-jar}” />

<!– Properties –>

<property name=”sdk.dir” value=”E:\dev\android-sdk-windows”/>

<!– 是否采取签名 –>

 

<property name=”android.tools.dir” location=”${sdk.dir}/tools” />

<sourcefolder refid=”project.libraries.src” />

<!– signing mode: release –>

<property name=”android.platform.tools.dir”
location=”${sdk.dir}/platform-tools” />

</target>

<element name=”extra-jars” optional=”yes” />

<if condition=”${proguard.enabled}”>

<subant target=”compile”>

<isreference refid=”out.dex.jar.input.ref” />

<target name=”-compile-tested-if-test” if=”tested.project.dir”
unless=”do.not.compile.again”>

<target name=”-dex” depends=”compile, -post-compile, optimize”
unless=”do.not.compile”>

 

 

<src path=”${gen.absolute.dir}” />

                     If true:

</then>

<delete file=”${obfuscated.jar.file}” />

</else>

 

 

 

</if>

<then>

<xpath input=”AndroidManifest.xml”
expression=”/manifest/application/@android:debuggable”
output=”build.packaging.debug” default=”false” />

 

 

<os family=”windows” />

</target>

</then>

                    -libraryjars ${android.libraryjars}

<property name=”filter.abi” value=”” />

<arg value=”-dontwarn” />

<target name=”-release-nosign” unless=”has.keystore”>

</path>

<then>

<if condition=”${proguard.enabled}”>

<!– This is needed by emma as it uses multilevel verbosity instead
of simple ‘true’ or ‘false’

<arg value=”-dontusemixedcaseclassnames” />

<!– Directory for the third party java libraries –>

<!– 创建文件夹–>

<?xml version=”1.0″ encoding=”UTF-8″?>

</java>

<!– Generates the R.java file for this project’s resources. –>

                    -outjars ${obfuscated.jar.file}

<property name=”out.unaligned.file.name”
value=”${ant.project.name}-unaligned.apk” />

</target>

<target name=”-pre-compile” />

<!– 

</then>

<!– Signs the APK –>

<!–别人的<jar basedir=”${out-folder}”
destfile=”temp.jar”/>–>

</subant>

<arg value=”-keep public class * extends
android.content.ContentProvider” />

<property name=”preobfuscate.jar.file”
value=”${obfuscate.absolute.dir}/original.jar” />

<sequential>

<arg line=”${adb.device.arg}” />

<!–签名相关的key –>

<arg path=”@{out.package}” />

 

</target>

             Override the following targets in your build.xml, before
the call to <setup>

<!– properties for signing in release mode –>

<mkdir dir=”${out.classes.absolute.dir}” />

<condition property=”has.password” value=”passwordxxxxx”>

<property name=”proguard-jar”
value=”${proguard.home}/lib/proguard.jar” />

 

              This actually can create multiple resource package in case

 

<aidl executable=”${aidl}” framework=”${android.aidl}”
genFolder=”${gen.absolute.dir}”>

</target>

<echo>Installing ${out.debug.file} onto default emulator or
device…</echo>

<property name=”intermediate.dex.file”
location=”${out.absolute.dir}/${dex.file.name}” />

<!–<arg value=”-dontskipnonpubliclibraryclassmembers”/>–>

 

<jarfolder path=”${jar.libs.absolute.dir}” />

<!– sets the primary input for dex. If a pre-dex task sets it to

<condition property=”verbose.option” value=”–verbose” else=””>

                             when using Ant before 1.8 –>

</exec>

<target name=”-aidl” depends=”-dirs”>

<isset property=”key.alias” />

<property name=”out.classes.dir” value=”${out.absolute.dir}/classes”
/>

              value.–>

<arg value=”-f” />

 

<property name=”out.absolute.dir” location=”${out.dir}” />

<echo>Converting compiled files and external libraries into
${intermediate.dex.file}…</echo>

             This is only active in release builds when proguard.config
is defined

<!– sdk的路径 –>

                 -obfuscate

<!– This is needed to switch verbosity of dx. Depends exclusively on
‘verbose’ –>

 

<property name=”verbose” value=”false” />

 

              declared in default.properties.

 

<echo>Signing final apk…</echo>

<property name=”build.signing.debug” value=”false” />

 

<arg value=”-keep public class * extends android.app.Service” />

<echo>Gets passwords ${has.keystore} ${has.password}</echo>

</target>

              by the custom tasks receiving them. –>

 

<!– set the secondary dx input: the project (and library) jar files

 

<echo>and run zipalign from the Android SDK tools.</echo>

<path id=”jar.libs.ref”>

<!– This is needed to switch verbosity of zipalign. Depends
exclusively on ‘verbose’

</condition>

</then>

              debug, -debug-with-emma and release.–>

 

</macrodef>

</else>

<dex-helper />

<arg value=”-keep public class * extends
android.content.BroadcastReceiver” />

<echo>*************************************************</echo>

<macrodef name=”zipalign-helper”>

<path id=”emma.lib”>

<property name=”source.absolute.dir” location=”${source.dir}” />

<property name=”verbose” value=”false” />

<source refid=”project.libraries.src” />

<target name=”clean” description=”Removes output files created by
other targets.”>

<sequential>

<fileset dir=”${extensible.libs.classpath}” includes=”*.jar” />

<taskdef resource=”emma_ant.properties” classpathref=”emma.lib”
/>

</if>

<property name=”aapt.resource.filter” value=”” />

<!– Tells adb which device to target. You can change this from the
command line

<then>

              –>

<property name=”build.mode.debug” value=”true” />

</macrodef>

<project name=”xiyou_base_” default=”deployableAllDevice”>

<arg value=”-dontskipnonpubliclibraryclasses” />

<property name=”out.release.file”
location=”${out.absolute.dir}/${out.release.file.name}” />

前段时间做了一个android的网游项目,现在优化减少体积与防别人反编译,需要将编译后.class进行模糊,开始在网上看了部分有关
ProGuard的介绍,基本上都是运ADT自带的从包方,那个包方式最好慢了,还要手工输密码,一个字烦。

<jarfolder refid=”project.libraries.libs” />

 

<property name=”project.jars” refid=”project.jars.ref” />

<nativefolder path=”${native.libs.absolute.dir}” />

 

<then>

<!– signing mode: debug –>

<mkdir dir=”${obfuscate.absolute.dir}” />

</target>

</path>

</if>

<!– called through target ‘release’. Only executed if the keystore
and

<!– 源文件与资源路 –>

<property name=”adb.device.arg” value=”” />

<istrue value=”${verbose}” />

<property name=”has.password” value=”true” />

<!– Custom tasks –>

<path refid=”out.dex.jar.input.ref” />

  1. [代码][xml]代码     跳至 [1] [全屏预览]

                    -verbose

 

<arg value=”-keep public class * extends android.view.View” />

<property name=”out.dir” value=”out” />

              -install-with-emma which do exactly the same but differ in
dependencies –>

</target>

 

<!– Packages the application without signing it. –>

</path>

</if>

<!– Gets passwords –>

<else>

<taskdef name=”aidl” classname=”com.android.ant.AidlExecTask”
classpathref=”android.antlibs” />

<isset property=”key.store.password” />

<path id=”android.antlibs”>

<if condition=”${manifest.hasCode}”>

<property name=”version.code” value=”” />

<target name=”-dirs”>

 

 

                    –>

<property name=”out.dex.input.absolute.dir”
value=”${obfuscated.jar.file}” />

<isset property=”build.mode.release” />

 

 

</sequential>

                    -keep public class * extends android.app.Activity

              –>

 

<property name=”key.alias” value=”key.keystore” />

<element name=”extra-parameters” optional=”yes” />

<property name=”java.encoding” value=”UTF-8″ />

<arg value=”install” />

              </package-helper> –>

<!– 签名相关的密码 –>

<!– create a path with all the jar files, from the main project and
the

</javac>

</target>

                             all the jar files separated by a platform
path-separator.

                             files. –>

</target>

 

<!– proguard is never enabled in debug mode –>

</macrodef>

<!– java源文件编码,编译的目标平台,为1.5 or 1.6且可以 –>

<arg value=”-dontpreverify” />

<!– This is macro that enable passing variable list of external jar
files to ApkBuilder

                         Set property out.dex.input.absolute.dir to be
the output of the obfuscation

<echo>Debug Package: ${out.debug.file}</echo>

</condition>

<!– Obfuscate target

</then>

<src refid=”project.libraries.src” />

<isset property=”key.alias.password” />

</then>

                 -release-obfuscation-check

<!– This runs -package-release and -release-nosign first and then
runs

<echo>Running zip align on final apk…</echo>

 

<echo>Creating output directories if needed…</echo>

 

<target name=”-pre-build” />

 

<isset property=”tested.project.absolute.dir” />

<!– Secondary dx input (jar files) is empty since all the

<echo>**** Android Manifest has debuggable=true
****</echo>

<echo>Generating R.java / Manifest.java from the
resources…</echo>

                    -keep public class * extends android.app.Service

</condition>

<taskdef name=”if” classname=”com.android.ant.IfElseTask”
classpathref=”android.antlibs” />

                    -optimizations
!code/simplification/arithmetic,!field/*,!class/merging/*

<arg value=”–dex” />

<!– set some properties used for filtering/override. If those
weren’t defined

              only if release-sign is true (set in -release-check,

</condition>

<property name=”gen.absolute.dir” location=”${gen.dir}” />

 

<arg value=”-allowaccessmodification” />

<istrue value=”${verbose}” />

<aapt executable=”${aapt}” command=”package”
versioncode=”${version.code}” debug=”${build.packaging.debug}”
manifest=”AndroidManifest.xml” assets=”${asset.absolute.dir}”
androidjar=”${android.jar}” apkfolder=”${out.absolute.dir}”
resourcefilename=”${resource.package.file.name}”
resourcefilter=”${aapt.resource.filter}”>

<condition>

</then>

<path refid=”project.libraries.jars” />

<!–<mkdir dir=”${out-folder}”/>

<arg line=”${verbose.option}” />

<property name=”has.keystore” value=”true” />

<property name=”jar.libs.dir” value=”libs” />

               <unzip src=”optimized.jar” dest=”${out-folder}”/>

 

<property name=”out.dex.input.absolute.dir”
value=”${out.classes.absolute.dir}” />

<!– Converts this project’s .class files into .dex files –>

<!– Creates the output directories if they don’t exist yet. –>

 

<if>

<path id=”out.dex.jar.input.ref” />

<signjar jar=”${out.unsigned.file}” signedjar=”${out.unaligned.file}”
keystore=”${key.store}” storepass=”${key.store.password}”
alias=”${key.alias}” keypass=”${key.alias.password}”
verbose=”${verbose}” />

<source path=”${source.absolute.dir}” />

 

<!–<delete dir=”${out-folder}”/>–>

<property name=”resource.dir” value=”res” />

<else>

<property name=”gen.dir” value=”gen” />

<!– 签名密码 –>

<!– Set the android classpath Path object into a single property.
It’ll be

 –>

                     Check whether obfuscation should happen, and put
the result in a property.

</then>

                    -optimizationpasses 5

              output dex filename and external libraries to dex
(optional) –>

<!– Emma configuration –>

                    -dontusemixedcaseclassnames

                  </extra-jars>

<condition property=”exe” value=”.exe” else=””>

<!– <nocompress /> forces no compression on any files in
assets or res/raw –>

<else>

<property name=”native.libs.dir” value=”libs” />

 

 

                             jar files will be in the obfuscated jar
–>

<!– Value of the hasCode attribute (Application node) extracted from
manifest file –>

                        If a pre-dex task sets it to something else this
has no effect –>

<input message=”Please enter keystore password (store:${key.store}):”
addproperty=”key.store.password” defaultvalue=”5201314..” />

</macrodef>

<target name=”-package-debug-sign” depends=”-dex,
-package-resources”>

<!– <nocompress extension=”xml” /> forces no compression on
specific file extensions in assets and res/raw –>

<mkdir dir=”${resource.absolute.dir}” />

</condition>

<mkdir dir=”${gen.absolute.dir}” />

<target name=”-release-obfuscation-check”>

<macrodef name=”dex-helper”>

<!– This is macro used only for sharing code among two targets,
-install and

<property name=”out.debug.file”
location=”${out.absolute.dir}/${ant.project.name}-debug.apk” />

</else>

<property name=”obfuscate.absolute.dir”
location=”${out.absolute.dir}/proguard” />

<arg value=”–output=${intermediate.dex.file}” />

<isset property=”key.store” />

</else>

<exec executable=”${adb}” failonerror=”true”>

 

<condition property=”extensible.classpath”
value=”${tested.project.absolute.dir}/${out.dir}/classes” else=”.”>

 

<and>

         –>

<!– property only set in release mode.

 

<condition property=”extensible.libs.classpath”
value=”${tested.project.absolute.dir}/libs” else=”${jar.libs.dir}”>

              called by -release-no-sign)–>

<property name=”java.source” value=”1.5″ />

<target name=”release” depends=”-set-release-mode,
-release-obfuscation-check, -package-release,
-release-prompt-for-password, -release-nosign” if=”has.keystore”
description=”Builds the application. The generated apk file must be
signed before

<target name=”-release-prompt-for-password” if=”has.keystore”
unless=”has.password”>

                             tested project’s location –>

 

 

<property name=”jar.libs.absolute.dir” location=”${jar.libs.dir}”
/>

</aapt>

<property name=”out.unsigned.file.name”
value=”${ant.project.name}-unsigned.apk” />

</aidl>

              your build.xml and it’ll be called instead of this one.
–>

<!– If android rules are used for a test project, its classpath
should include

<!–<target name=”-dex” depends=”compile, -post-compile,
-obfuscate” unless=”do.not.compile”>–>

哼吧,废话不说了,直接上build文件 

<!– Add Proguard Tasks –>

 

                  <extra-jars>

                         Perform obfuscation

</target>

<res path=”${resource.absolute.dir}” />

              <package-helper output.filepath=”/path/to/foo.apk”>

</if>

<!– called through target ‘release’. Only executed if there’s no

<arg path=”${out.debug.file}” />

<target name=”-set-release-mode”>

<property name=”out.release.file.name”
value=”${ant.project.name}-release.apk” />

 

                -repackageclasses

<property name=”out.unsigned.file”
location=”${out.absolute.dir}/${out.unsigned.file.name}” />

 

</then>

             To replace Proguard with a different obfuscation engine:

<property name=”native.libs.absolute.dir”
location=”${native.libs.dir}” />

<property name=”obfuscated.jar.file”
value=”${obfuscate.absolute.dir}/obfuscated.jar” />

<echo>hasCode = false. Skipping…</echo>

<mkdir dir=”${out.absolute.dir}” />

<then>

 

<property name=”emma.dir” value=”${sdk.dir}/tools/lib” />

<arg path=”${out.dex.input.absolute.dir}” />

                     Obfuscation should not happen. Set the same
property to false.

</target>

</exec>

<arg value=”-outjars ${out.dir}/out/classes” />

<!– empty default pre-compile target. Create a similar target in

<taskdef name=”apkbuilder” classname=”com.android.ant.ApkBuilderTask”
classpathref=”android.antlibs” />

</target>

<then>

proguard.config=proguard.cfg

<then>

<!– property only set in debug mode.

</and>

<!–
uid和sdk都是自定义参数,可发出可随便,有差不多多少只保险要起,就当此处copy多小行,修改有关参数,传入到程序里即可
–>

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

<javac encoding=”${java.encoding}” source=”${java.source}”
target=”${java.target}” debug=”true” extdirs=””
destdir=”${out.classes.absolute.dir}”
bootclasspathref=”android.target.classpath” verbose=”${verbose}”
classpath=”${extensible.classpath}” classpathref=”jar.libs.ref”>

<echo>**** Doing DEBUG packaging with RELEASE keys
****</echo>

<sourcefolder path=”${source.absolute.dir}” />

</condition>

</else>

<property name=”proguard.enabled” value=”true” />

<arg value=”4″ />

 

<dex path=”${intermediate.dex.file}” />

<condition property=”verbosity” value=”verbose” else=”quiet”>

 

              key alias are known but not their password. –>

<!– Rules –>

<target name=”deployableAllDevice” description=”build all device
packet”>

<pathelement location=”${preobfuscate.jar.file}” />

              before, then this will create them with empty values,
which are then ignored

<jvmarg value=”-Dmaximum.inlined.code.length=32″ />

                        something else this has no effect –>

</if>

                   Useful for if/unless attributes in target node

<!– End of emma configuration –>

<attribute name=”in.package” />

<proguard>

</target>

</target>

<jar basedir=”${out.classes.dir}” destfile=”${preobfuscate.jar.file}”
/>

                             all the jar files separated by a platform
path-separator.

<istrue value=”${verbose}” />

<!– Generates java classes from .aidl files. –>

<mkdir dir=”${jar.libs.absolute.dir}” />

</condition>

<zipalign-helper in.package=”${out.unaligned.file}”
out.package=”${out.release.file}” />

<property name=”key.store.password” value=”xxxx” />

                    -keep public class * extends
android.content.ContentProvider

<property name=”proguard.home”
value=”D:/software/j2me/proguard4.5.1/proguard4.5.1″/>

<!– whether the build is a debug build. always set. –>

<pathelement path=”${sdk.dir}/tools/lib/sdklib.jar” />

                    -injars ${project.jars}

<macrodef name=”install-helper”>

                    -keep public class
com.android.vending.licensing.ILicensingService

                             Useful for if/unless attributes in target
node

</target>

                    -keep public class * extends
android.app.Application

</path>

<!– 生成的混淆Class位置–>

<path id=”out.dex.jar.input.ref”>

</sequential>

<aapt executable=”${aapt}” command=”package” verbose=”${verbose}”
manifest=”AndroidManifest.xml” androidjar=”${android.jar}”
rfolder=”${gen.absolute.dir}”>

<path id=”project.jars.ref”>

<!– empty default pre-build target. Create a similar target in

<echo>No key.store and key.alias properties found in
build.properties.</echo>

</target>

<and>

<target name=”-obfuscate” unless=”do.not.compile”>

<if condition=”${build.packaging.debug}”>

<macrodef name=”package-helper”>

<!– release mode is only valid if the manifest does not explicitly

<xpath input=”AndroidManifest.xml” expression=”/manifest/@package”
output=”manifest.package” />

<!– Macros –>

</sequential>

<target name=”debug” depends=”-set-debug-mode,
-compile-tested-if-test, -package-debug-sign” description=”Builds the
application and signs it with a debug key.”>

<taskdef name=”xpath” classname=”com.android.ant.XPathTask”
classpathref=”android.antlibs” />

<!– Set the project jar files Path object into a single property.
It’ll be

<property name=”proguard.jar”
location=”${proguard.home}/lib/proguard.jar” />

<target name=”-post-compile” />

                     <jarfolder path=”my_jars” />

<!– Verbosity –>

 

 

<antcall target=”release” inheritAll=”true”><param name=”uid”
value=”100″ /><param name=”sdk” value=”91″ /></antcall>

</path>

<apply executable=”${dx}” failonerror=”true” parallel=”true”>

</target>

         proper rules.

</else>

<!– Directory for the native libraries –>

<if condition=”${manifest.hasCode}”>

<echo>Packaging resources</echo>

<target name=”-debug-obfuscation-check”>

</target>

<attribute name=”out.package” />

<condition property=”proguard.enabled” value=”true” else=”false”>

<isset property=”proguard.config” />

<package-helper output.filepath=”${out.unsigned.file}” />

default.properties 内容

                    <arg value=” -libraryjars
${library-jar}/some_lib_used.jar”/>

</if>

 

 

                        –>

<target name=”optimize” depends=”compile,-obfuscate”>

<setup import=”false” />

<!– Compiles this project’s .java files into .class files. –>

<echo>hasCode = false. Skipping…</echo>

 

<!– 输出路径 –>

<fileset dir=”${jar.libs.absolute.dir}” includes=”*.jar” />

</condition>

ps:我们项目还有一个奇异要求,要将本号,推广ID打到保险里去,方便做推广什么的。这里可以就此replace的办法对string.xml进行修改

<if condition=”${proguard.enabled}”>

<!– 混淆相关参数 –>

</condition>

<property name=”adb”
location=”${android.platform.tools.dir}/adb${exe}” />

 

<!–这些是本的Jar<delete file=”temp.jar”/>–>

 

<delete dir=”${gen.absolute.dir}” verbose=”${verbose}” />

<delete dir=”${out.absolute.dir}” verbose=”${verbose}” />

<condition property=”v.option” value=”-v” else=””>

<sequential>

<pathelement path=”${sdk.dir}/tools/lib/anttasks.jar” />

                     <jarfile path=”foo/bar.jar” />

<path refid=”jar.libs.ref” />

<then>

<pathelement path=”${sdk.dir}/tools/lib/androidprefs.jar” />

              keystore/key alias set –>

<!– Custom Android task to deal with the project target, and import
the

<property name=”out.debug.unaligned.file”
location=”${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk”
/>

 

                -allowaccessmodification

<if condition=”${manifest.hasCode}”>

<!– Tools –>

哼吧,看来得动自己了,!@#¥@#!@#!@##¥@#¥!@#@
转眼一到,我++,终于将东西作出来

<target name=”pre” depends=”-obfuscate”>

<!– Configurable macro, which allows to pass as parameters output
directory,

</target>

<attribute name=”output.filepath” />

<apkbuilder outfolder=”${out.absolute.dir}”
resourcefile=”${resource.package.file.name}”
apkfilepath=”@{output.filepath}”
debugpackaging=”${build.packaging.debug}”
debugsigning=”${build.signing.debug}” abifilter=”${filter.abi}”
verbose=”${verbose}” hascode=”${manifest.hasCode}”>

</sequential>

 

         This requires ant 1.6.0 or above. –>

 

<res path=”${resource.absolute.dir}” />

                     <jarfolder path=”your_jars” />

<echo>hasCode = false. Skipping…</echo>

<!– Build a path object with all the jar files that must be
obfuscated.

<target name=”-resource-src” depends=”-dirs, -pre-build”>

 

<!– input for dex will be proguard’s output –>

 

<!– Name of the application package extracted from manifest file
–>

 

</apply>

<!– proguard4的路径 –>

<then>

<!– Packages the application and sign it with a debug key. –>

</and>

<if condition=”${manifest.hasCode}”>

<else>

target=android-4

</project>

 

 

<arg path=”@{in.package}” />

<property name=”resource.absolute.dir” location=”${resource.dir}”
/>

                             This include the project compiled source
code and any 3rd party jar

              different values –>

<echo>Release Package: ${out.release.file}</echo>

              your build.xml and it’ll be called instead of this one.
–>

<src path=”${source.absolute.dir}” />

                    -keep public class * extends
android.content.BroadcastReceiver

<java jar=”${proguard-jar}” fork=”true” failonerror=”true”>

</if>

              Example of use:

<fileset dir=”${tested.project.absolute.dir}” includes=”build.xml”
/>

<arg value=”-optimizationpasses 7″ />

<length string=”${key.store}” when=”greater” length=”0″ />

<property name=”android-jar”
value=”${sdk.dir}/platforms/${target}/android.jar” />

</apkbuilder>

<target name=”compile” depends=”-resource-src, -aidl, -pre-compile”
description=”Compiles project’s .java files into .class files”>

              your build.xml and it’ll be called instead of this one.
–>

                    -dontskipnonpubliclibraryclasses

<echo>Compiling aidl files into Java classes…</echo>

<property name=”build.packaging.debug” value=”true” />

<delete file=”${preobfuscate.jar.file}” />

<target name=”-package-resources”>

<!– Zip aligns the APK –>

 

<property name=”build.mode.release” value=”true” />

             in default.properties.

 

</if>

 

<extra-jars />

<!– Intermediate files –>

<!– Builds debug output package, provided all the necessary files
are already dexed –>

</target>

</condition>

<classpath>

 

<isset property=”tested.project.absolute.dir” />

              the emulator. –>

               <delete file=”optimized.jar”/>–>

<property name=”java.target” value=”1.5″ />

 

<property name=”source.dir” value=”src” />

<!– Puts the project’s resources into the output package file

<property name=”asset.dir” value=”assets” />

<antcall target=”release” inheritAll=”true”><param name=”uid”
value=”101″ /><param name=”sdk” value=”90″ /></antcall>

<external-libs />

<taskdef name=”proguard” classname=”proguard.ant.ProGuardTask”
classpath=”${proguard.jar}” />

<extra-parameters />

<!– This is macro which zipaligns in.package and outputs it to
out.package. Used by targets

<echo>Please sign ${out.unsigned.file} manually</echo>

<!– empty default post-compile target. Create a similar target in

<zipalign-helper in.package=”${out.debug.unaligned.file}”
out.package=”${out.debug.file}” />

<else>

<taskdef name=”aapt” classname=”com.android.ant.AaptExecLoopTask”
classpathref=”android.antlibs” />

</if>

于是乎从头找寻ant+proguard+签名的从包方,遗憾之是材料不是缺手就是断脚。

                           it is published.”>

              Some custom apk with specific configuration have been

<condition property=”has.keystore” value=”true”>

              These can be overridden by setting them earlier to

<isset property=”has.keystore” />

<arg line=”${v.option}” />

<package-helper output.filepath=”${out.debug.unaligned.file}” />

                   set debuggable to true. default is false.

<path refid=”jar.libs.ref” />

 

<!– The final package file to generate

<property name=”proguard.enabled” value=”true” />

<arg value=”-injars ${out.dir}/classes” />

                 -debug-obfuscation-check

<property name=”out.unaligned.file”
location=”${out.absolute.dir}/${out.unaligned.file.name}” />

</and>

                    -dontpreverify

<echo>hasCode = false. Skipping…</echo>

              by invoking “ant -Dadb.device.arg=-d” for device “ant
-Dadb.device.arg=-e” for

<property name=”key.store” value=”key.keystore” />

 

 

<property name=”dex.file.name” value=”classes.dex” />

发表评论

电子邮件地址不会被公开。 必填项已用*标注