Skip to content

Instantly share code, notes, and snippets.

@VladimirCores
Last active November 3, 2017 22:08
Show Gist options
  • Save VladimirCores/818a0dbec95e61ffda12bb9c87c659af to your computer and use it in GitHub Desktop.
Save VladimirCores/818a0dbec95e61ffda12bb9c87c659af to your computer and use it in GitHub Desktop.
Ant script to build Android APK (armv7 or x86) and connect it to FDB at specific IP
<?xml version="1.0"?>
<project name="Application">
<property name="sdk.air" value="PATH_TO_AIR_SDK_FOLDER"/>
<property name="adt" value="${sdk.air}/bin/adt.bat"/>
<property name="ip" value="192.168.0.101"/>
<property name="project.root" value="."/>
<property name="dir.cert" value="${project.root}/CERTIFICATE_FOLDER"/>
<property name="dir.release" value="${project.root}/RELEASE_FOLDER"/>
<property name="dir.temp" value="temp"/>
<property name="dir.bin" value="bin"/>
<property name="dir.src" value="src"/>
<property name="assets.icons" value="icons"/>
<property name="app.name" value="APPLICATION_NAME"/>
<property name="app.main" value="MAIN_CLASS"/>
<property name="app.descriptor" value="${app.main}-app.xml"/>
<property name="app.id" value="COM_APPLICATION_ID"/>
<property name="air.arch.arm" value="armv7"/>
<property name="air.arch.amd" value="x86"/>
<property name="air.arch" value="${air.arch.arm}"/>
<property name="air.name" value="${app.name}-${air.arch}.apk"/>
<property name="air.storetype" value="pkcs12"/>
<target name="init">
<mkdir dir="${dir.temp}"/>
<copy todir="${dir.temp}">
<fileset dir="${dir.bin}"/>
</copy>
</target>
<target name="process" depends="init">
<exec executable="${adt}" failonerror="true">
<arg line="-package"/>
<!-- AIR_SIGNING_OPTIONS -->
<arg line="-target apk-debug"/>
<!-- DEBUGGER_CONNECTION_OPTIONS -->
<arg line="-connect ${ip}"/>
<!-- <arg line="-listen 16000"/> -->
<arg line="-arch ${air.arch}"/>
<!-- NATIVE_SIGNING_OPTIONS -->
<arg line="-storetype ${air.storetype}"/>
<arg line="-keystore ${dir.cert}/${app.name}.p12"/>
<arg line="-storepass KEY_PASS"/>
<!-- output -->
<arg line="${dir.release}/${air.name}"/>
<!-- app_descriptor -->
<arg line="${dir.temp}/${app.descriptor}"/>
<!-- FILE_OPTIONS -->
<arg line="-C ${dir.temp}"/>
<arg line="${app.main}.swf"/>
<arg line="-C ${dir.temp}" />
<arg line="${assets.icons}" />
</exec>
</target>
<target name="package" depends="process, clean"></target>
<!-- Install on device -->
<target name="install" depends="package" description="Installs the last created .apk file on your attached device">
<exec executable="adb">
<arg line="install -d -r"/>
<arg line="${dir.release}/${air.name}"/>
</exec>
<!--
<exec executable="${adt}">
<arg line="-installApp"/>
<arg line="-platform android"/>
<arg line="-device"/>
<arg line="${device.id}"/>
<arg line="-package"/>
<arg line="${dir.release}/${air.name}"/>
</exec>
-->
</target>
<!-- Launch on device -->
<target name="launch" depends="install" description="Launches the app on your device">
<exec executable="${adt}">
<arg line="-launchApp"/>
<arg line="-platform ${air.platform}"/>
<!-- <arg line="-platformsdk ${android.sdk}"/>-->
<arg line="-appid ${app.id}"/>
</exec>
</target>
<target name="clean" description="clean up">
<delete dir="${dir.temp}"/>
</target>
</project>
@VladimirCores
Copy link
Author

VladimirCores commented Nov 3, 2017

Things to replace - ALL_CAPITAL_WORDS:

  1. PATH_TO_AIR_SDK_FOLDER
  2. CERTIFICATE_FOLDER
  3. RELEASE_FOLDER
  4. APPLICATION_NAME
  5. MAIN_CLASS
  6. COM_APPLICATION_ID
  7. KEY_PASS
    and of course IP

I suggest that your main class has the same name as output .swf file

<initialWindow>
    <content>MAIN_CLASS.swf</content>
    <renderMode>direct</renderMode>
    ...
</initialWindow>

And you have icons in a folder

<icon>
    <image40x40>icons/icon_40.png</image40x40>
    <image48x48>icons/icon_48.png</image48x48>
    <image57x57>icons/icon_57.png</image57x57>
...
</icon>

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