Changed the project names for the two Android clients to disambiguate them.
[zxing.git] / android / build.xml
index fa69b0c..49d21aa 100644 (file)
@@ -1,5 +1,4 @@
-<?xml version="1.0" ?>
-
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
  Copyright (C) 2008 Google Inc.
 
 
 <!-- This is a mildly hacked version of the auto-generated project
      build.xml file. -->
-<project name="BarcodeReader" default="package">
+<project name="BarcodeReaderM5" default="package">
   <property file="../build.properties"/>
   <property name="sdk-folder" value="${android-home}"/>
   <property name="android-tools" value="${sdk-folder}/tools"/>
+  <property name="android-framework" value="${android-tools}/lib/framework.aidl"/>
 
   <!-- The intermediates directory -->
   <!-- Eclipse uses "bin" for its own output, so we do the same. -->
   <property name="intermediate-dex" value="${outdir}/${dex-file}"/>
 
   <!-- The final package file to generate -->
-  <property name="out-package" value="${outdir}/${ant.project.name}.apk"/>
+  <property name="out-package" value="${outdir}/BarcodeReader.apk"/>
 
   <!-- Tools -->
   <property name="aapt" value="${android-tools}/aapt"/>
   <property name="aidl" value="${android-tools}/aidl"/>
   <property name="dx" value="${android-tools}/dx"/>
+  <property name="adb" value="${android-tools}/adb" />
+  <property name="android-jar" value="${sdk-folder}/android.jar" />
   <property name="zip" value="zip"/>
-  <property name="android-jar" value="${sdk-folder}/android.jar"/>
 
   <!-- Rules -->
 
 
   <!-- Generate the R.java file for this project's resources. -->
   <target name="resource-src" depends="dirs">
+
+    <copy file="strings.xml.template" tofile="res/values/strings.xml" overwrite="true">
+      <filterset>
+        <filter token="VERSION" value="${version}"/>
+      </filterset>
+    </copy>
+
     <echo>Generating R.java...</echo>
     <exec executable="${aapt}" failonerror="true">
       <arg value="compile"/>
   <!-- Generate java classes from .aidl files. -->
   <target name="aidl" depends="dirs">
     <apply executable="${aidl}" failonerror="true">
+      <arg value="-p${android-framework}"/>
+      <arg value="-I${srcdir}"/>
       <fileset dir="${srcdir}">
         <include name="**/*.aidl"/>
       </fileset>
   </target>
 
   <!-- Compile this project's .java files into .class files. -->
-  <target name="compile" depends="init, dirs, resource-src, aidl">
+  <target name="compile" depends="init, clean, dirs, resource-src, aidl">
     <javac encoding="ascii" target="1.5" debug="true" optimize="true" extdirs=""
            srcdir="."
            destdir="${outdir-classes}"
   <target name="optimize" depends="compile" unless="debug">
     <jar basedir="${outdir-classes}" destfile="temp.jar"/>
     <java jar="${WTK-home}/bin/proguard.jar" fork="true" failonerror="true">
+     <jvmarg value="-Dmaximum.inlined.code.length=32"/>
      <arg value="-injars temp.jar"/>
      <arg value="-outjars optimized.jar"/>
      <arg value="-libraryjars ${android-jar}"/>
      <arg value="-dontpreverify"/>
      <arg value="-dontobfuscate"/>
      <arg value="-keep public class com.google.zxing.client.android.BarcodeReaderCaptureActivity"/>
-     <arg value="-optimizationpasses 4"/>
+     <arg value="-optimizationpasses 7"/>
+     <arg value="-overloadaggressively"/>
      <arg value="-verbose"/>
    </java>
    <delete file="temp.jar"/>
       <arg value="--output=${intermediate-dex}"/>
       <arg value="--locals=${locals}"/>
       <arg value="--positions=${positions}"/>
-      <arg path="${outdir-classes}"/>
+      <arg path="${basedir}/${outdir-classes}"/>
     </exec>
   </target>
 
@@ -236,7 +248,11 @@ only when the assets dir exists. -->
          update="true"/>
   </target>
 
-  <!-- Put the project's .dex files into the output package file. -->
+  <!-- Put the project's .dex files into the output package file.
+       Use the "zip" command, available on most un*x/Linux/MacOS systems,
+       to create the new package (Ant 1.7 has an internal 'zip' command,
+       however Ant 1.6.5 lacks it and is still widely installed.)
+  -->
   <target name="package-dex" depends="dex, package-res">
     <echo>Packaging dex...</echo>
     <exec executable="${zip}" failonerror="true">
@@ -249,6 +265,15 @@ only when the assets dir exists. -->
   <!-- Create the package file for this project from the sources. -->
   <target name="package" depends="package-dex"/>
 
+  <!-- Install package on the default emulator -->
+  <target name="install">
+    <echo>Sending package to default emulator...</echo>
+    <exec executable="${adb}" failonerror="true">
+      <arg value="install" />
+      <arg value="${out-package}" />
+    </exec>
+  </target>
+
   <target name="clean">
     <delete dir="${outdir}"/>
   </target>