Skip to content

Instantly share code, notes, and snippets.

@tpryan
Created July 13, 2010 22:54
Show Gist options
  • Save tpryan/474691 to your computer and use it in GitHub Desktop.
Save tpryan/474691 to your computer and use it in GitHub Desktop.
ant files for building and installing AIR for Android applications
flex.path= [Path to folder containing Flex SDKs]
flex.sdkVersion=[The name of the Flex SDK you wish to use]
flex.sdkPath=${flex.path}/${flex.sdkVersion}
FLEX_HOME=${flex.sdkPath}
contentText=[This value will be overwritten by Flash Builder in the output app.xml]
ADB = [Path to the Android SDK ADB File]
ADT = ${flex.sdkPath}/bin/adt
cert = [Path to the cert file you wish to sign app with]
cert.password = [Password for cert, considering prompting instead]
dev.dir=src
build.dir=bin-release
projectFile=${dev.dir}/${app.name}.${app.type}
swfFile=${build.dir}/${app.name}.swf
app.name=Main
app.type=mxml
<?xml version="1.0" encoding="UTF-8"?>
<project name="ProjectName" basedir=".">
<property file="settings.properties"/>
<!-- path to the flex task libraries. -->
<path id="flextasks.classpath">
<fileset dir="${FLEX_HOME}/ant/lib">
<include name="*.jar"/>
</fileset>
</path>
<typedef resource="flexTasks.tasks" classpathref="flextasks.classpath" />
<target name="main" depends="compile,package,install" />
<target name="clean">
<echo message="Cleaning Build Space"/>
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="clean">
<echo message="Compiling swf"/>
<mxmlc file="${projectFile}" output="${swfFile}">
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<static-link-runtime-shared-libraries />
</mxmlc>
<echo message="Copying Assets"/>
<copy todir="${build.dir}/assets" preservelastmodified="true">
<fileset dir="${dev.dir}/assets">
<exclude name='.gitignore'/>
<exclude name='**/.DS_Store'/>
</fileset>
</copy>
<echo message="Copying Application Description File"/>
<copy todir="${build.dir}" preservelastmodified="true">
<fileset file="${dev.dir}/${app.name}-app.xml" />
</copy>
<echo message="Modifying Application Description File"/>
<replace file="${build.dir}/${app.name}-app.xml">
<replacefilter token="${contentText}" value="${app.name}.swf" />
</replace>
</target>
<target name="package">
<echo message="Packaging for Android"/>
<exec executable="${ADT}" dir="${build.dir}">
<arg value="-package"/>
<arg line="-target apk"/>
<arg line="-storetype pkcs12"/>
<arg line="-keystore ${cert}" />
<arg line="-storepass ${cert.password}" />
<arg value="${app.name}"/>
<arg value="${app.name}-app.xml"/>
<arg value="${app.name}.swf"/>
<arg value="assets"/>
</exec>
</target>
<target name="install">
<echo message="Installing onto attached Android Device"/>
<exec executable="${ADB}">
<arg value="install"/>
<arg value="-r"/>
<arg value="${build.dir}/${app.name}.apk"/>
</exec>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment