Skip to content

Instantly share code, notes, and snippets.

@kristoferjoseph
Created October 16, 2010 19:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristoferjoseph/630170 to your computer and use it in GitHub Desktop.
Save kristoferjoseph/630170 to your computer and use it in GitHub Desktop.
An example ant script used for developing Adobe AIR applications for Android
<?xml version="1.0"?>
<project name="Notes" default="debug-phone">
<property file="build.properties"/>
<property name="deploy.dir" value="deploy"/>
<property name="src.dir" value="src"/>
<property name="assets.dir" value="assets"/>
<property name="flex.mxmlc" value="${flex.sdk}/bin/mxmlc"/>
<property name="flex.compc" value="${flex.sdk}/bin/compc"/>
<property name="air.amxmlc" value="${flex.sdk}/bin/amxmlc"/>
<property name="air.adl" value="${flex.sdk}/bin/amxmlc"/>
<property name="air.adt" value="${flex.sdk}/bin/adt"/>
<property name="app.name" value="Notes"/>
<property name="app.descriptor" value="Notes-app.xml"/>
<property name="app.id" value="com.developsigner.Notes"/>
<property name="app.version" value="Pre Alpha 1"/>
<property name="project.root" value="."/>
<property name="air.name" value="Notes.apk"/>
<property name="air.assets" value="assets"/>
<property name="air.storetype" value="PKCS12"/>
<property name="air.keystore" value="CodeCert.pfx"/>
<property name="air.platform" value="android"/>
<property name="android.adb" value="${android.sdk}tools/adb"/>
<!-- Prepare Project -->
<target name="prep" description="Runs the initial steps **WARNING** This must be done once defore any other targets" depends="clean,create_certificate"/>
<!-- Copy Assets -->
<target name="copy" description="Copies dependencies">
<!-- Copy air description file -->
<copy file="${src.dir}/${app.descriptor}" tofile="${deploy.dir}/${app.descriptor}"/>
<!-- Copy Certificate file -->
<copy file="${project.root}/${air.keystore}" tofile="${deploy.dir}/${air.keystore}"/>
<!-- Copy over the Flash assets swc -->
<copy file="${assets.dir}/flash/NotesAssets.swc" tofile="lib/NotesAssets.swc" overwrite="true"/>
</target>
<!-- Compile -->
<target name="build" description="Compiles the project SWF">
<exec executable="${air.amxmlc}" failonerror="true">
<arg line="${src.dir}/Notes.as"/>
<arg line="-output ${deploy.dir}/Notes.swf"/>
</exec>
</target>
<!-- Debug -->
<target name="debug" description="Runs all the steps to create a debug apk" depends="clean,copy,build,package-debug"/>
<!-- Debug in ADL -->
<target name="debug-adl" description="Runs all the steps needed to debug in ADL" depends="clean,copy,build,package-debug,launch-adl"/>
<!-- Debug on Phone -->
<target name="debug-phone" description="Launches the debug apk on a usb connected phone" depends="clean,copy,build,package-debug,uninstall,install,launch"/>
<!-- Package Debug -->
<target name="package-debug" description="Packages the current project with debugging enabled as a debug-apk">
<exec executable="${air.adt}" failonerror="true">
<!-- To package debug apk -->
<arg line="-package"/>
<arg line="-target apk-debug"/>
<arg line="-storetype ${air.storetype}"/>
<arg line="-keystore ${deploy.dir}/${air.keystore}"/>
<arg line="-storepass ${air.storepass}"/>
<arg line="${air.name}"/>
<arg line="${deploy.dir}/${app.descriptor}"/>
<!-- <arg line="${android.sdk}"/> -->
<arg line="${deploy.dir}/${app.name}.swf"/>
<arg line="-C ${deploy.dir} ${app.name}.swf" />
<!-- <arg line="-C ${deploy.dir} ${air.assets}" /> -->
</exec>
</target>
<!-- Launch ADL -->
<target name="launch-adl" description="Launches app in ADL">
<exec executable="${air.adl}" failonerror="true">
<arg line="-profile mobileDevice"/>
<arg line="-screensize NexusOne"/>
<arg line="${deploy.dir}/${app.descriptor}"/>
</exec>
</target>
<!-- Release -->
<target name="release" description="Runs the targets needed for a release build" depends="clean,copy,build,package-release" />
<target name="deploy-release" description="Installs the release build on a usb connected phone" depends="clean,copy,build,package-release,uninstall,install,launch" />
<!-- Package -->
<target name="package-release" description="Packages up you Air application for release as an apk">
<exec executable="${air.adt}" failonerror="true">
<arg line="-package"/>
<arg line="-target apk"/>
<arg line="-storetype ${air.storetype}"/>
<arg line="-keystore ${deploy.dir}/${air.keystore}"/>
<arg line="-storepass ${air.storepass}"/>
<arg line="${air.name}"/>
<arg line="${deploy.dir}/${app.descriptor}"/>
<arg line="${android.sdk}"/>
<arg line="${deploy.dir}/${app.name}.swf"/>
<arg line="-C ${deploy.dir} ${app.name}.swf" />
<!-- <arg line="-C ${deploy.dir} ${air.assets}" /> -->
</exec>
</target>
<!-- Phone Launcher -->
<target name="phone" description="Launches the current apk on a usb connected phone" depends="uninstall,install,launch"/>
<!-- Install on device -->
<target name="install" description="Installs the last created .apk file on your attached device">
<exec executable="${android.adb}">
<arg line="-d install"/>
<arg line="-r ${air.name}"/>
</exec>
</target>
<!-- Uninstall from device -->
<target name="uninstall" description="Uninstalls the application from the device">
<exec executable="${air.adt}">
<arg line="-uninstallApp"/>
<arg line="-platform ${air.platform}"/>
<arg line="-platformsdk ${android.sdk}"/>
<arg line="-appid ${app.id}"/>
</exec>
</target>
<!-- Launch on device -->
<target name="launch" description="Launches the app on your device">
<exec executable="${air.adt}">
<arg line="-launchApp"/>
<arg line="-platform ${air.platform}"/>
<arg line="-platformsdk ${android.sdk}"/>
<arg line="-appid ${app.id}"/>
</exec>
</target>
<!-- Create Cert -->
<target name="create_certificate" description="Creates a pk12 certificte">
<exec executable="${air.adt}" failonerror="true">
<arg line="-certificate"/>
<arg line="-cn self_signed"/>
<arg line="2048-RSA"/>
<arg line="${project.root}/CodeCert.pfx"/>
<arg line="${air.storepass}"/>
</exec>
</target>
<!-- Clean -->
<target name="clean" description="Removes previous build artifacts">
<delete dir="${deploy.dir}"/>
<mkdir dir="${deploy.dir}"/>
</target>
<!-- Run Tests -->
<target name="run-tests" description="Does all the steps needed to run tests in a flash player" depends="clean,test,open-tests"/>
<!-- Test -->
<target name="test" description="Runs the current project tests in the test runner application">
<exec executable="${flex.mxmlc}" failonerror="true">
<arg line="${src.dir}/NotesTestRunner.as"/>
<arg line="-output ${deploy.dir}/NotesTestRunner.swf"/>
</exec>
</target>
<target name="open-tests" description="Opens the test runner SWF">
<exec executable="Open" failonerror="true">
<arg line="${deploy.dir}/NotesTestRunner.swf"/>
</exec>
</target>
</project>
flex.sdk=/Path/to/your/Flex/sdk
android.sdk=/Path/to/your/Android/sdk
air.storepass=P4$$W0rd
@kristoferjoseph
Copy link
Author

This will require a custom build.properties file to specify all of the user specific properties

@kristoferjoseph
Copy link
Author

Thanks @clintmodien for the ant hookup I am not going to use that Java env.Stupid syntax though.

@joshon
Copy link

joshon commented Oct 7, 2011

Thanks - VERY useful
Using Windows 7 I had to change the adt info to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment