- 浏览: 212916 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
xiegqooo:
fbb_11 写道如果以前都正常,而突然不正常了,正常的思路应 ...
思考才能有效的解决问题----<WEB应用在捕捉异常并处理时,请不要使用System.exit(1)!!!! > -
ilotuo:
Nice! Thank for sharing your ex ...
Ogre xcode build error: Reference to 'FileInfo' is ambiguous -
Stark_Summer:
赞 就是感觉过于概念了。还是不能很明白
ANSI和Unicode中的汉字编码 (转) -
landerson:
旧版的ANTTASK.JAR与新版的ANT-TASK.JAR ...
ant 优化android 项目编译第二波,simple编译项目只需1分钟 -
luopenger:
taskdef com.android.ant.SetupTa ...
使用ant优化android项目编译速度,提高工作效率
由于第一次的脚本在改动java文件后仍需约五分钟,现进行第二次优化,
上片请进 http://liuqzan.iteye.com/blog/951995
分析:编译耗时主要在资源文件引用的生成和资源文件的打包与二进制处理流程中
对于一个只修改了java文件的项目而言,无需重新执行资源文件的打包与二进制流程
上一个ant 在只修改了java文件的时候编译仍需5mins因为重复生成 二进制 资源文件,此步可以在没有资源文件更改的情况下,只需执行过一次,以后编译时可以省去
ant 脚本优化生成三个功能:
1:generate R: 更新R文件 耗时约4mins
2:package-resources : 在有资源文件改变的情况下打包生成资源文件,耗时约4 mins
3:simple: 在没有资源文件改变,只改变的JAVA相关文件,且之前执行过一次package-resources ,生成apk只需一分钟。
针对以前三种开发情境,现在处理:
在资源文件更改, 不用生成apk,只需要使用资源引用的情况(5%) :使用命令 ant generateR 只更新R文件 耗时 约4mins
更新了资源文件,又修改了JAVA文件想立即生成apk,(5%) 则联合使用:ant generateR à ant package-resources à ant simple 约10mins
频繁修改java类文件,资源文件不变,只需要生成apk(90%):使用命令ant simple ,耗时约 1mins
优点:
可操作性强,三个处理流相互独立,处理时互不影响 。
节约时间,定制编译
缺点:需要手动使用ant 命令
<?xml version="1.0" encoding="UTF-8"?> <project name="Reader" > <!-- The local.properties file is created and updated by the 'android' tool. It contains the path to the SDK. It should *NOT* be checked into Version Control Systems. --> <property file="local.properties" /> <!-- The build.properties file can be created by you and is never touched by the 'android' tool. This is the place to change some of the default property values used by the Ant rules. Here are some properties you may want to change/update: source.dir The name of the source directory. Default is 'src'. out.dir The name of the output directory. Default is 'bin'. Properties related to the SDK location or the project target should be updated using the 'android' tool with the 'update' action. This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <property file="build.properties" /> <!-- The default.properties file is created and updated by the 'android' tool, as well as ADT. This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <property file="default.properties" /> <!-- Custom Android task to deal with the project target, and import the proper rules. This requires ant 1.6.0 or above. --> <path id="android.antlibs"> <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" /> <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" /> </path> <taskdef name="setup" classname="com.android.ant.SetupTask" classpathref="android.antlibs" /> <!-- extension targets. Uncomment the ones where you want to do custom work in between standard targets --> <!-- <target name="-pre-build"> </target> <target name="-pre-compile"> </target> [This is typically used for code obfuscation. Compiled code location: ${out.classes.absolute.dir} If this is not done in place, override ${out.dex.input.absolute.dir}] <target name="-post-compile"> </target> --> <!-- Execute the Android Setup task that will setup some properties specific to the target, and import the build rules files. The rules file is imported from <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml To customize existing targets, there are two options: - Customize only one target: - copy/paste the target into this file, *before* the <setup> task. - customize it to your needs. - Customize the whole script. - copy/paste the content of the rules files (minus the top node) into this file, *after* the <setup> task - disable the import of the rules by changing the setup task below to <setup import="false" />. - customize to your needs. --> <setup import="false"/> <!-- This rules file is meant to be imported by the custom Ant task: com.android.ant.SetupTask The following properties are put in place by the importing task: android.jar, android.aidl, aapt, aidl, and dx Additionnaly, the task sets up the following classpath reference: android.target.classpath This is used by the compiler task as the boot classpath. --> <!-- Custom tasks --> <taskdef name="aapt" classname="com.android.ant.AaptExecLoopTask" classpathref="android.antlibs" /> <taskdef name="aidl" classname="com.android.ant.AidlExecTask" classpathref="android.antlibs" /> <taskdef name="apkbuilder" classname="com.android.ant.ApkBuilderTask" classpathref="android.antlibs" /> <taskdef name="xpath" classname="com.android.ant.XPathTask" classpathref="android.antlibs" /> <taskdef name="if" classname="com.android.ant.IfElseTask" classpathref="android.antlibs" /> <taskdef name="nowtime" classname="AntNowTime" classpath="."/> <!-- Properties --> <!-- Tells adb which device to target. You can change this from the command line by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for the emulator. --> <property name="adb.device.arg" value="" /> <property name="android.tools.dir" location="${sdk.dir}/tools" /> <!-- Name of the application package extracted from manifest file --> <xpath input="AndroidManifest.xml" expression="/manifest/@package" output="manifest.package" /> <!-- Value of the debuggable attribute (Application node) extracted from manifest file --> <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable" output="manifest.debuggable" default="false"/> <!-- Value of the debuggable attribute (Application node) extracted from manifest file --> <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:hasCode" output="manifest.hasCode" default="true"/> <!-- Input directories --> <property name="source.dir" value="src" /> <property name="source.absolute.dir" location="${source.dir}" /> <property name="gen.dir" value="gen" /> <property name="gen.absolute.dir" location="${gen.dir}" /> <property name="resource.dir" value="res" /> <property name="resource.absolute.dir" location="${resource.dir}" /> <property name="asset.dir" value="assets" /> <property name="asset.absolute.dir" location="${asset.dir}" /> <!-- Directory for the third party java libraries --> <property name="external.libs.dir" value="${reader_libs}" /> <property name="external.libs.absolute.dir" location="${external.libs.dir}" /> <!-- Directory for the native libraries --> <property name="native.libs.dir" value="libs" /> <property name="native.libs.absolute.dir" location="${native.libs.dir}" /> <!-- Output directories --> <property name="out.dir" value="bin" /> <property name="out.absolute.dir" location="${out.dir}" /> <property name="out.classes.dir" value="${out.absolute.dir}" /> <property name="out.classes.absolute.dir" location="${out.classes.dir}" /> <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" /> <!-- Intermediate files --> <property name="dex.file.name" value="classes.dex" /> <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" /> <property name="resource.package.file.name" value="${ant.project.name}.ap_" /> <!-- The final package file to generate These can be overridden by setting them earlier to different values --> <property name="out.debug.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" /> <property name="out.debug.file" location="${out.absolute.dir}/${ant.project.name}-debug.apk" /> <property name="out.unsigned.file.name" value="${ant.project.name}-unsigned.apk" /> <property name="out.unsigned.file" location="${out.absolute.dir}/${out.unsigned.file.name}" /> <property name="out.unaligned.file.name" value="${ant.project.name}-unaligned.apk" /> <property name="out.unaligned.file" location="${out.absolute.dir}/${out.unaligned.file.name}" /> <property name="out.release.file.name" value="${ant.project.name}-release.apk" /> <property name="out.release.file" location="${out.absolute.dir}/${out.release.file.name}" /> <!-- set some properties used for filtering/override. If those weren't defined before, then this will create them with empty values, which are then ignored by the custom tasks receiving them. --> <property name="version.code" value="" /> <property name="aapt.resource.filter" value="" /> <property name="filter.abi" value="" /> <!-- Verbosity --> <property name="verbose" value="false" /> <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false' The property 'verbosity' is not user configurable and depends exclusively on 'verbose' value.--> <condition property="verbosity" value="verbose" else="quiet"> <istrue value="${verbose}" /> </condition> <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose' --> <condition property="v.option" value="-v" else=""> <istrue value="${verbose}" /> </condition> <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' --> <condition property="verbose.option" value="--verbose" else=""> <istrue value="${verbose}" /> </condition> <!-- properties for signing in release mode --> <condition property="has.keystore"> <and> <isset property="key.store" /> <length string="${key.store}" when="greater" length="0" /> <isset property="key.alias" /> </and> </condition> <condition property="has.password"> <and> <isset property="has.keystore" /> <isset property="key.store.password" /> <isset property="key.alias.password" /> </and> </condition> <!-- Tools --> <condition property="exe" value=".exe" else=""><os family="windows" /></condition> <property name="adb" location="${android.tools.dir}/adb${exe}" /> <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" /> <!-- Emma configuration --> <property name="emma.dir" value="${sdk.dir}/tools/lib" /> <path id="emma.lib"> <pathelement location="${emma.dir}/emma.jar" /> <pathelement location="${emma.dir}/emma_ant.jar" /> </path> <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> <!-- End of emma configuration --> <!-- Macros --> <!-- Configurable macro, which allows to pass as parameters output directory, output dex filename and external libraries to dex (optional) --> <macrodef name="dex-helper"> <element name="external-libs" optional="yes" /> <element name="extra-parameters" optional="yes" /> <sequential> <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo> <apply executable="${dx}" failonerror="true" parallel="true"> <arg value="--dex" /> <arg value="--output=${intermediate.dex.file}" /> <extra-parameters /> <arg line="${verbose.option}" /> <arg path="${out.dex.input.absolute.dir}" /> <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> <path refid="android.libraries.jars" /> <external-libs /> </apply> </sequential> </macrodef> <!-- This is macro that enable passing variable list of external jar files to ApkBuilder Example of use: <package-helper sign.package="true" output.filepath="/path/to/foo.apk"> <extra-jars> <jarfolder path="my_jars" /> <jarfile path="foo/bar.jar" /> <jarfolder path="your_jars" /> </extra-jars> </package-helper> --> <macrodef name="package-helper"> <attribute name="sign.package" /> <attribute name="output.filepath" /> <element name="extra-jars" optional="yes" /> <sequential> <apkbuilder outfolder="${out.absolute.dir}" resourcefile="${resource.package.file.name}" apkfilepath="@{output.filepath}" signed="@{sign.package}" debug="${manifest.debuggable}" abifilter="${filter.abi}" verbose="${verbose}" hascode="${manifest.hasCode}"> <dex path="${intermediate.dex.file}"/> <sourcefolder path="${source.absolute.dir}"/> <sourcefolder refid="android.libraries.src"/> <jarfolder path="${external.libs.absolute.dir}" /> <jarfolder refid="android.libraries.libs" /> <nativefolder path="${native.libs.absolute.dir}" /> <nativefolder refid="android.libraries.libs" /> <extra-jars/> </apkbuilder> </sequential> </macrodef> <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets debug, -debug-with-emma and release.--> <macrodef name="zipalign-helper"> <attribute name="in.package" /> <attribute name="out.package" /> <sequential> <echo>Running zip align on final apk...</echo> <exec executable="${zipalign}" failonerror="true"> <arg line="${v.option}" /> <arg value="-f" /> <arg value="4" /> <arg path="@{in.package}" /> <arg path="@{out.package}" /> </exec> </sequential> </macrodef> <!-- This is macro used only for sharing code among two targets, -install and -install-with-emma which do exactly the same but differ in dependencies --> <macrodef name="install-helper"> <sequential> <echo>Installing ${out.debug.file} onto default emulator or device...</echo> <exec executable="${adb}" failonerror="true"> <arg line="${adb.device.arg}" /> <arg value="install" /> <arg value="-r" /> <arg path="${out.debug.file}" /> </exec> </sequential> </macrodef> <!-- Rules --> <target name="use" description="Use the Task" > <nowtime/> </target> <!-- Creates the output directories if they don't exist yet. --> <target name="-dirs"> <echo>Creating output directories if needed...</echo> <mkdir dir="${resource.absolute.dir}" /> <mkdir dir="${external.libs.absolute.dir}" /> <mkdir dir="${out.absolute.dir}" /> <if condition="${manifest.hasCode}"> <then> <mkdir dir="${gen.absolute.dir}" /> <mkdir dir="${out.classes.absolute.dir}" /> </then> </if> </target> <!-- empty default pre-build target. Create a similar target in your build.xml and it'll be called instead of this one. --> <target name="-pre-build"/> <!-- Generates the R.java file for this project's resources. --> <target name="generateR" depends="cleanR,-dirs, -pre-build"> <if condition="${manifest.hasCode}"> <then> <echo>Generating R.java / Manifest.java from the resources...</echo> <nowtime/> <aapt executable="${aapt}" command="package" verbose="${verbose}" manifest="AndroidManifest.xml" androidjar="${android.jar}" rfolder="${gen.absolute.dir}"> <res path="${resource.absolute.dir}" /> </aapt> <nowtime/> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> </target> <!-- Generates java classes from .aidl files. --> <target name="-aidl" depends="-dirs"> <if condition="${manifest.hasCode}"> <then> <echo>Compiling aidl files into Java classes...</echo> <aidl executable="${aidl}" framework="${android.aidl}" genFolder="${gen.absolute.dir}"> <source path="${source.absolute.dir}"/> <source refid="android.libraries.src"/> </aidl> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> </target> <!-- empty default pre-compile target. Create a similar target in your build.xml and it'll be called instead of this one. --> <target name="-pre-compile"/> <!-- Compiles this project's .java files into .class files. --> <target name="compile" depends="generateR, -aidl, -pre-compile" description="Compiles project's .java files into .class files"> <if condition="${manifest.hasCode}"> <then> <!-- If android rules are used for a test project, its classpath should include tested project's location --> <condition property="extensible.classpath" value="${tested.project.absolute.dir}/bin/classes" else="."> <isset property="tested.project.absolute.dir" /> </condition> <condition property="extensible.libs.classpath" value="${tested.project.absolute.dir}/libs" else="./libs"> <isset property="tested.project.absolute.dir" /> </condition> <javac encoding="GBK" target="1.5" debug="true" extdirs="" destdir="${out.classes.absolute.dir}" bootclasspathref="android.target.classpath" verbose="${verbose}" classpath="${extensible.classpath}" classpathref="android.libraries.jars"> <src path="${reader_service_project}/src" /> <src path="${reader_data_project}/src" /> <src path="${reader_service_project}/gen" /> <src path="${reader_data_project}/gen" /> <src path="${source.absolute.dir}" /> <src path="${gen.absolute.dir}" /> <src refid="android.libraries.src" /> <classpath> <fileset dir="${reader_lib_project}/lib" includes="*.jar" /> <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> </classpath> </javac> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> </target> <!-- Compiles this project's .java files into .class files. --> <target name="simplecompile" depends="-pre-compile" description="Compiles project's .java files into .class files"> <echo>simplecompile start at time</echo><nowtime/> <if condition="${manifest.hasCode}"> <then> <!-- If android rules are used for a test project, its classpath should include tested project's location --> <condition property="extensible.classpath" value="${tested.project.absolute.dir}/bin/classes" else="."> <isset property="tested.project.absolute.dir" /> </condition> <condition property="extensible.libs.classpath" value="${tested.project.absolute.dir}/libs" else="./libs"> <isset property="tested.project.absolute.dir" /> </condition> <javac encoding="GBK" target="1.5" debug="true" extdirs="" destdir="${out.classes.absolute.dir}" bootclasspathref="android.target.classpath" verbose="${verbose}" classpath="${extensible.classpath}" classpathref="android.libraries.jars"> <src path="${reader_service_project}/src" /> <src path="${reader_data_project}/src" /> <src path="${reader_service_project}/gen" /> <src path="${reader_data_project}/gen" /> <src path="${source.absolute.dir}" /> <src path="${gen.absolute.dir}" /> <src refid="android.libraries.src" /> <classpath> <fileset dir="${reader_lib_project}/lib" includes="*.jar" /> <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> </classpath> </javac> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> <echo>simplecompile end at time</echo><nowtime/> </target> <!-- empty default post-compile target. Create a similar target in your build.xml and it'll be called instead of this one. --> <target name="-post-compile"/> <!-- Converts this project's .class files into .dex files --> <target name="-dex" depends="simplecompile, -post-compile" unless="do.not.compile"> <if condition="${manifest.hasCode}"> <then> <dex-helper /> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> </target> <!-- Converts this project's .class files into .dex files --> <target name="-simpledex" depends="simplecompile, -post-compile" unless="do.not.compile"> <echo>-simpledex start at time</echo><nowtime/> <if condition="${manifest.hasCode}"> <then> <dex-helper /> </then> <else> <echo>hasCode = false. Skipping...</echo> </else> </if> <echo>-simpledex end at time</echo><nowtime/> </target> <!-- Puts the project's resources into the output package file This actually can create multiple resource package in case Some custom apk with specific configuration have been declared in default.properties. --> <target name="-package-resources"> <echo>Packaging resources start at time</echo> <echo>Packaging resources start at time</echo><nowtime/> <aapt executable="${aapt}" command="package" versioncode="${version.code}" manifest="AndroidManifest.xml" assets="${asset.absolute.dir}" androidjar="${android.jar}" apkfolder="${out.absolute.dir}" resourcefilename="${resource.package.file.name}" resourcefilter="${aapt.resource.filter}"> <res path="${resource.absolute.dir}" /> <!-- <nocompress /> forces no compression on any files in assets or res/raw --> <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw --> </aapt> <echo>Packaging resources end at time</echo><nowtime/> </target> <target name="package-resources" > <echo>Packaging resources start at time</echo> <echo>Packaging resources start at time</echo><nowtime/> <aapt executable="${aapt}" command="package" versioncode="${version.code}" manifest="AndroidManifest.xml" assets="${asset.absolute.dir}" androidjar="${android.jar}" apkfolder="${out.absolute.dir}" resourcefilename="${resource.package.file.name}" resourcefilter="${aapt.resource.filter}"> <res path="${resource.absolute.dir}" /> <!-- <nocompress /> forces no compression on any files in assets or res/raw --> <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw --> </aapt> <echo>Packaging resources end at time</echo><nowtime/> </target> <!-- Packages the application and sign it with a debug key. --> <target name="-package-debug-sign" depends="-dex, -package-resources"> <package-helper sign.package="true" output.filepath="${out.debug.unaligned.file}" /> </target> <!-- Packages the application and sign it with a debug key. --> <target name="-simplepackage-debug-sign" depends="-simpledex, -package-resources"> <package-helper sign.package="true" output.filepath="${out.debug.unaligned.file}" /> </target> <!-- Packages the application and sign it with a debug key. --> <target name="-simplepackage" depends="-simpledex"> <package-helper sign.package="true" output.filepath="${out.debug.unaligned.file}" /> </target> <!-- Packages the application without signing it. --> <target name="-package-release" depends="-dex, -package-resources"> <package-helper sign.package="false" output.filepath="${out.unsigned.file}"/> </target> <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again"> <subant target="compile"> <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> </subant> </target> <target name="-simplecompile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again"> <subant target="simplecompile"> <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> </subant> </target> <!-- Builds debug output package, provided all the necessary files are already dexed --> <target name="debug" depends="-compile-tested-if-test, -package-debug-sign" description="Builds the application and signs it with a debug key."> <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> <echo>Debug Package: ${out.debug.file}</echo> </target> <!-- Builds debug output package, provided all the necessary files are already dexed --> <target name="simpledebug" depends="-simplecompile-tested-if-test, -simplepackage-debug-sign" description="Builds the application and signs it with a debug key."> <echo>Debug Package: ${out.debug.unaligned.file}</echo> <!-- <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> <echo>Debug Package: ${out.debug.file}</echo> --> </target> <!-- Builds debug output package, provided all the necessary files are already dexed --> <target name="simple" depends="-simplecompile-tested-if-test, -simplepackage" description="Builds the application and signs it with a debug key."> <echo>Debug Package: ${out.debug.unaligned.file}</echo> <!-- <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> <echo>Debug Package: ${out.debug.file}</echo> --> </target> <!-- called through target 'release'. Only executed if the keystore and key alias are known but not their password. --> <target name="-release-prompt-for-password" if="has.keystore" unless="has.password"> <!-- Gets passwords --> <input message="Please enter keystore password (store:${key.store}):" addproperty="key.store.password" /> <input message="Please enter password for alias '${key.alias}':" addproperty="key.alias.password" /> </target> <!-- called through target 'release'. Only executed if there's no keystore/key alias set --> <target name="-release-nosign" unless="has.keystore"> <echo>No key.store and key.alias properties found in build.properties.</echo> <echo>Please sign ${out.unsigned.file} manually</echo> <echo>and run zipalign from the Android SDK tools.</echo> </target> <target name="-set-release-mode"> <property name="build.mode.release" value="true"/> </target> <!-- This runs -package-release and -release-nosign first and then runs only if release-sign is true (set in -release-check, called by -release-no-sign)--> <target name="release" depends="-set-release-mode, -package-release, -release-prompt-for-password, -release-nosign" if="has.keystore" description="Builds the application. The generated apk file must be signed before it is published."> <!-- Signs the APK --> <echo>Signing final apk...</echo> <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}" /> <!-- Zip aligns the APK --> <zipalign-helper in.package="${out.unaligned.file}" out.package="${out.release.file}" /> <echo>Release Package: ${out.release.file}</echo> </target> <target name="install" depends="debug" description="Installs/reinstalls the debug package onto a running emulator or device. If the application was previously installed, the signatures must match." > <install-helper /> </target> <target name="-uninstall-check"> <condition property="uninstall.run"> <isset property="manifest.package" /> </condition> </target> <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run"> <echo>Unable to run 'ant uninstall', manifest.package property is not defined. </echo> </target> <!-- Uninstalls the package from the default emulator/device --> <target name="uninstall" depends="-uninstall-error" if="uninstall.run" description="Uninstalls the application from a running emulator or device."> <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo> <exec executable="${adb}" failonerror="true"> <arg line="${adb.device.arg}" /> <arg value="uninstall" /> <arg value="${manifest.package}" /> </exec> </target> <target name="clean" description="Removes output files created by other targets."> <delete dir="${out.absolute.dir}" verbose="${verbose}" /> <delete dir="${gen.absolute.dir}" verbose="${verbose}" /> </target> <target name="cleanR" description="Removes R.java file created by other targets."> <delete dir="${gen.absolute.dir}" verbose="${verbose}" /> </target> <!-- Targets for code-coverage measurement purposes, invoked from external file --> <!-- Emma-instruments tested project classes (compiles the tested project if necessary) and writes instrumented classes to ${instrumentation.absolute.dir}/classes --> <target name="-emma-instrument" depends="compile"> <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo> <!-- It only instruments class files, not any external libs --> <emma enabled="true"> <instr verbosity="${verbosity}" mode="overwrite" instrpath="${out.absolute.dir}/classes" outdir="${out.absolute.dir}/classes"> </instr> <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from user defined file --> </emma> </target> <target name="-dex-instrumented" depends="-emma-instrument"> <dex-helper> <extra-parameters> <arg value="--no-locals" /> </extra-parameters> <external-libs> <fileset file="${emma.dir}/emma_device.jar" /> </external-libs> </dex-helper> </target> <!-- Invoked from external files for code coverage purposes --> <target name="-package-with-emma" depends="-dex-instrumented, -package-resources"> <package-helper sign.package="true" output.filepath="${out.debug.unaligned.file}"> <extra-jars> <!-- Injected from external file --> <jarfile path="${emma.dir}/emma_device.jar" /> </extra-jars> </package-helper> </target> <target name="-debug-with-emma" depends="-package-with-emma"> <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> </target> <target name="-install-with-emma" depends="-debug-with-emma"> <install-helper /> </target> <!-- End of targets for code-coverage measurement purposes --> <target name="help"> <echo>Modified Android Ant Build. Available targets:</echo> <echo> generateR: Generates the R.java file for this project's resources.</echo> <echo> simplecompile: Compiles project's .java files into .class files.</echo> <echo> simpledebug: Builds the application and signs it with a debug key.</echo> <!-- displays starts at col 13 |13 80| --> <echo>Android Ant Build. Available targets:</echo> <echo> help: Displays this help.</echo> <echo> clean: Removes output files created by other targets.</echo> <echo> compile: Compiles project's .java files into .class files.</echo> <echo> debug: Builds the application and signs it with a debug key.</echo> <echo> release: Builds the application. The generated apk file must be</echo> <echo> signed before it is published.</echo> <echo> install: Installs/reinstalls the debug package onto a running</echo> <echo> emulator or device.</echo> <echo> If the application was previously installed, the</echo> <echo> signatures must match.</echo> <echo> uninstall: Uninstalls the application from a running emulator or</echo> <echo> device.</echo> </target> </project>
评论
3 楼
landerson
2015-06-22
旧版的ANTTASK.JAR与新版的ANT-TASK.JAR 不一样的,所以在使用新版的SDK TOOLS时会出现1,2楼的错
2 楼
glanze
2013-06-26
BUILD FAILED
test.xml:46: taskdef class com
.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[]
请问这个是什么地方需要配置么? 本机sdk没有发现对应的jar包
test.xml:46: taskdef class com
.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[]
请问这个是什么地方需要配置么? 本机sdk没有发现对应的jar包
1 楼
soyul
2011-06-24
你好,下面这个错误是什么地方没有配置引起的吗?
D:\project\GameWorkspace\antTest\build.xml:465: Reference android.libraries.src not found.
D:\project\GameWorkspace\antTest\build.xml:465: Reference android.libraries.src not found.
发表评论
-
GDB调试精粹及使用实例
2012-01-09 00:58 780一:列文件清单 1 ... -
gdb cannot exec /bin/sh on android local terminal
2012-01-08 23:52 1502http://letsgoustc.spaces.liv ... -
android opengl lifecycle with ndk
2012-01-04 10:29 743http://www.brokenteapotstudios. ... -
android ndk source code
2011-12-30 00:12 817http://android.yongbok.net/repo ... -
使用GDB调试Android NDK开发的程序
2011-12-24 16:03 1143对于使用NDK编译出来的工具除了so库文件外,会会有gdbs ... -
更新Android SDK, 升级ADT遇到的问题总结
2011-12-24 15:18 4329本文能解决的问题: 1.android sdk, ... -
jmonkey sdk 3 support android
2011-12-05 00:29 1106http://jmonkeyengine.org/groups ... -
[转]adb shell 无法启动 (insufficient permissions for device)
2011-10-05 21:01 1816使用adb shell出现错误: error: in ... -
3d资料记录
2011-09-23 10:36 701World, View and Projection Matr ... -
android emulator启动超级慢解决方法
2011-07-01 14:43 1278手动写一个bat --》 emulator.exe -cpu ... -
opengl and blender in action
2011-06-28 17:49 778http://adampreble.net/blog/2011 ... -
自定义 Theme 改变 系统全局样式
2011-03-30 16:44 1885转自:http://www.androidworks.co ... -
Recommend blog about android
2011-03-28 16:20 826http://letsgoustc.spaces.live.c ... -
为TextView添加上下边框
2011-03-14 11:19 5006In android 2.2 you could do t ... -
在Eclipse中查看Android SDK源码
2011-03-14 10:34 960在SDK目录下面的platforms\android-X\ 建 ... -
使用ant优化android项目编译速度,提高工作效率
2011-03-10 12:09 12324在通常的Android大中型项目开发中,使用Ecli ... -
box2d 文档及Physics 相关知识
2011-02-25 14:59 1050http://www.box2d.org/manual.htm ... -
极品Opengl ES 教程
2011-02-22 16:38 1563http://duriansoftware.com/joe/A ... -
使用Mercurial从Google Code获得 项目源代码
2011-02-18 10:58 1287在Google Code上看到一个心动的项目源代码? 想要获得 ... -
EGL接口介绍(转)
2011-02-12 15:32 1377EGL 是 OpenGL ES 和底层 Native ...
相关推荐
Ant是一个基于Java的构建工具,它通过XML描述项目构建规则,使得构建过程可配置且易于自动化。 首先,让我们了解一下Ant。Ant是由Apache软件基金会开发的开源工具,主要用于Java项目的构建和管理。它的核心理念是...
在Android开发过程中,构建工具是不可或缺的一部分,它们帮助开发者自动化处理项目编译、打包和测试等任务。本示例中的"AntTest演示工程"就是专为展示如何利用Apache Ant工具来构建Android应用程序而设计的。Ant是一...
ANT作为一款开源的Java编译工具,在Android项目构建中扮演着重要的角色。本文将详细介绍如何利用ANT实现Android项目的自动编译、打包以及签名过程。 #### 二、准备工作 1. **下载并安装ANT**: - 访问ANT官网下载...
在Android开发过程中,Ant是一个非常重要的工具,它是一个开源的Java构建系统,广泛用于自动化编译、测试和部署Java应用程序,包括Android应用。本篇文章将详细介绍如何使用Ant来打包Android应用,以及涉及到的相关...
本文将深入探讨如何使用`Ant`脚本来编译并创建一个`JAR`文件,以此来理解`Ant`脚本的工作原理和实际应用。 `Ant`是Apache软件基金会开发的一款开源构建工具,它使用XML格式定义构建过程,具有高度可配置性和可扩展...
### Android Ant编译环境配置(Win) #### 一、引言 随着移动互联网技术的快速发展,Android 应用开发已成为软件开发领域中的一个重要分支。在早期的 Android 开发过程中,Ant 工具链被广泛应用于项目的构建与管理...
在Android开发过程中,构建工具是不可或缺的一部分,Ant作为早期广泛使用的构建工具,有着其独特的优点。本主题将深入探讨如何利用Ant进行多渠道打包和管理多个项目引用,这对于大型复杂项目或者需要针对不同市场...
通过ant脚本,编译打包android工程。 编译打包android工程的ant脚本,Android官方提供的打包脚本。 有注释
在Java 中应用是平台无关性的,当然不会用平台相关的make脚本来完成这些批处理任务了,ANT本身就是这样一个流程脚本引擎,用于自动化调用程序完成项目的编译,打包,测试等。本文介绍了android编译和ant打包原理
### Ant编译打包Android工程流程详解 #### 一、Ant编译打包步骤 ...综上所述,通过Ant工具,我们可以自动化完成Android项目的编译、打包、签名以及多渠道分发等一系列复杂的工作,极大地提高了开发效率。
Ant是Apache软件基金会的一个开源项目,它是一个Java构建工具,被广泛用于自动化Java应用程序的编译、测试、打包和部署等任务。在Android开发中,Ant同样扮演着至关重要的角色,因为它可以用来构建和管理Android项目...
### ant 管理整个项目的编译和运行 #### Ant工具概述 Ant(Another Neat Tool),是一款基于Java语言的构建工具,具有良好的跨平台能力。Ant使用XML文件来定义构建脚本,使得构建过程更加灵活且易于维护。通过Ant...
Apache Ant 编译命令总结 Apache Ant 是一个基于 Java 的生成工具,主要用来将源代码和其他输入文件转换为可执行文件的形式,或者转换为可安装的产品映像形式。Ant 在软件开发中扮演着重要角色,确保在每次生成期间...
Apache Ant是一个基于XML的构建工具,它允许开发者通过声明式的方式定义项目构建任务,而不是采用程序化的方式。在Java开发中,Ant常用于自动化编译、测试、打包和部署等任务。 首先,Ant的核心是构建文件`build....
本篇文章将深入探讨如何使用Ant自动打包编译Android应用,并重点介绍`custom_rules.xml`和`ant.properties`这两个配置文件的作用。 `Ant.properties`是Ant构建过程中的一个关键配置文件,它用于存储项目特定的属性...
Ant是Apache软件基金会的一个开源项目,它是一个基于Java的构建工具,主要用于自动化Java项目的构建、编译、测试和部署过程。在Java开发中,Ant以其灵活性和可扩展性而受到广泛应用,尤其在处理复杂的构建任务时。本...
2. **创建项目结构**:创建一个标准的Android项目目录结构,包括src、res、AndroidManifest.xml等必需的文件夹和文件。 3. **编写build.xml**:这是Ant的主要配置文件,定义了构建过程中的任务。它包括编译源代码、...
了解如何使用 Ant 构建 Android 应用不仅有助于理解 Android 构建过程的历史演变,也为开发者提供了另一种构建 Android 项目的可行方案。对于学习 Android 开发历史和技术演进的初学者来说,掌握 Ant 的使用仍然是有...
Apache Ant是Java开发中不可或缺的自动化构建工具,它在软件工程领域扮演着重要角色...对于“ant编译1.9版本”的学习,意味着掌握了一种有效管理和自动化Java项目开发的方法,这对于提升开发效率和维护性具有重要意义。
- 在Android项目中,需要在项目根目录下创建一个名为`build.xml`的文件,这是Ant的主要配置文件。 3. **构建Android项目** - 在`build.xml`中,需要定义目标(target)来执行不同的任务,如编译源代码、生成APK等...