Build Script for a Unity Android Project

Having learned how to integrate my Android code and resources with Unity, I went looking for a way to simplify the migration of my files to my Unity project. (I found repeatedly exporting a JAR and copying over the manifest and resource directories painful.) The result was this Ant script, which drops the class files, manifest, and resources directly into my Unity project.

<project default="build">
  <!-- Set this to your top-level Unity project directory! -->
    value="D:/rezcycle" />

  <!-- All Android files will be placed inside Assets/Plugins/Android. No 
    need to touch this. -->
    value="${project.dir}/Assets/Plugins/Android" />

  <target name="build">
    <!-- Make the assets directory in our project. -->
    <mkdir dir="${assets.dir}" />

    <!-- Copy over the manifest. -->
      todir="${assets.dir}" />

    <!-- Copy over the raw files in res/ and assets/. -->
    <copy todir="${assets.dir}">
        includes="res/**" />
        includes="assets/**" />

    <!-- Produce a JAR file of all your pre-compiled classes. Don't bring 
      R stuff. -->
    <jar destfile="${assets.dir}/custom_android.jar">
        excludes="**/R.class,**/R$*.class" />

I drop this in to my top-level Android project directory in Eclipse, naming it build.xml. Eclipse knows how to run Ant files, so I simply run as “Ant Build”.


  1. linfeng says:

    sorry my English not good ,i have a issue ask you,i use command line build an android project for untiy3D . next i want to build APK ,how can i do this.

Leave a Reply to linfeng Cancel reply

Your email address will not be published. Required fields are marked *