-<?xml version="1.0" ?>
-<project name="BarcodeScanner" default="debug">
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (C) 2008 ZXing authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project name="BarcodeScanner" default="debug-optimized">
<!-- SDK Locations -->
<property file="../build.properties"/>
<property name="sdk-folder" value="${android-home}"/>
<property name="android-tools" value="${sdk-folder}/tools"/>
<!-- Application Package Name -->
- <property name="application-package" value="com.android.barcodes" />
+ <property name="application-package" value="com.google.zxing.client.android" />
<!-- The intermediates directory -->
<!-- Eclipse uses "bin" for its own output, so we do the same. -->
</target>
<!-- Compile this project's .java files into .class files. -->
- <target name="compile" depends="dirs, resource-src, aidl">
+ <target name="compile" depends="clean, dirs, resource-src, aidl">
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
srcdir="."
destdir="${outdir-classes}"
</javac>
</target>
+ <target name="compile-release" depends="clean, dirs, resource-src, aidl">
+ <javac encoding="ascii" target="1.5" debug="off" extdirs=""
+ srcdir="."
+ destdir="${outdir-classes}"
+ bootclasspath="${android-jar}">
+ <classpath>
+ <fileset dir="${external-libs}" includes="*.jar"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <!--
+ Getting an error like this?
+
+ [apply] UNEXPECTED TOP-LEVEL EXCEPTION:
+ [apply] com.android.dx.cf.code.SimException: local variable type
+ mismatch: attempt to set or access a value of type int using a local
+ variable of type com.google.zxing.qrcode.decoder.Version. This is
+ symptomatic of .class transformation tools that ignore local variable
+ information.
+
+ Build core/ with the 'build-no-debug' target. It's a long story.
+ -->
+
+ <target name="optimize" depends="compile-release">
+ <fail message="Please put proguard.jar in 'bin' under the WTK install directory">
+ <condition>
+ <not>
+ <available file="${WTK-home}/bin/proguard.jar" type="file"/>
+ </not>
+ </condition>
+ </fail>
+ <unzip src="../core/core.jar" dest="${outdir-classes}" overwrite="true"/>
+ <jar jarfile="temp.jar" basedir="${outdir-classes}"/>
+ <delete dir="${outdir-classes}"/>
+ <mkdir dir="${outdir-classes}"/>
+ <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 temp-optimized.jar"/>
+ <arg value="-libraryjars ${android-jar}"/>
+ <arg value="-keep class com.google.zxing.client.android.*Activity"/>
+ <arg value="-keep class com.google.zxing.client.android.ViewfinderView { public * ; }"/>
+ <arg value="-keep class com.google.zxing.client.android.SearchBookContents* { public * ; }"/>
+ <arg value="-target 5"/>
+ <arg value="-optimizationpasses 7"/>
+ <arg value="-dontshrink"/>
+ <arg value="-dontobfuscate"/>
+ <arg value="-dontskipnonpubliclibraryclasses"/>
+ <arg value="-verbose"/>
+ <arg value="-dump proguard-dump.txt"/>
+ </java>
+ <delete file="temp.jar"/>
+ <unzip src="temp-optimized.jar" dest="${outdir-classes}" overwrite="true"/>
+ <delete file="temp-optimized.jar"/>
+ </target>
+
<!-- Convert this project's .class files into .dex files. -->
<target name="dex" depends="compile">
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
+ <echo>NOTE: This will fail unless you built core with build-no-debug.</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate-dex-ospath}" />
</apply>
</target>
+ <target name="dex-optimized" depends="compile-release,optimize">
+ <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
+ <echo>NOTE: This will fail unless you built core with build-no-debug.</echo>
+ <apply executable="${dx}" failonerror="true" parallel="true">
+ <arg value="--dex" />
+ <arg value="--output=${intermediate-dex-ospath}" />
+ <arg path="${outdir-classes-ospath}" />
+ <!-- workaround to appease 'apply'. Not really the right Ant task to use here. -->
+ <fileset dir="." includes="nosuchfile.jar"/>
+ </apply>
+ </target>
+
<!-- Put the project's resources into the output package file. -->
<target name="package-res-and-assets">
<echo>Packaging resources and assets...</echo>
</exec>
</target>
+ <!-- Package the optimized application and sign it with a debug key. -->
+ <target name="debug-optimized" depends="dex-optimized, package-res">
+ <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
+ <exec executable="${apk-builder}" failonerror="true">
+ <arg value="${out-debug-package-ospath}" />
+ <arg value="-z" />
+ <arg value="${resources-package-ospath}" />
+ <arg value="-f" />
+ <arg value="${intermediate-dex-ospath}" />
+ <arg value="-rf" />
+ <arg value="${srcdir-ospath}" />
+ <arg value="-rj" />
+ <arg value="${external-libs-ospath}" />
+ </exec>
+ </target>
+
<!-- Package the application without signing it.
This allows for the application to be signed later with an official publishing key. -->
- <target name="release" depends="dex, package-res">
+ <target name="release" depends="dex-optimized, package-res">
<echo>Packaging ${out-unsigned-package} for release...</echo>
<exec executable="${apk-builder}" failonerror="true">
<arg value="${out-unsigned-package-ospath}" />
<arg value="${intermediate-dex-ospath}" />
<arg value="-rf" />
<arg value="${srcdir-ospath}" />
- <arg value="-rj" />
- <arg value="${external-libs-ospath}" />
</exec>
<echo>It will need to be signed with jarsigner before being published.</echo>
</target>
<!-- Install the package on the default emulator -->
- <target name="install" depends="debug">
+ <target name="install">
<echo>Installing ${out-debug-package} onto default emulator...</echo>
<exec executable="${adb}" failonerror="true">
<arg value="install" />
</exec>
</target>
- <target name="reinstall" depends="debug">
+ <target name="reinstall">
<echo>Installing ${out-debug-package} onto default emulator...</echo>
<exec executable="${adb}" failonerror="true">
<arg value="install" />
<target name="clean">
<delete dir="${outdir}"/>
+ <delete file="proguard-dump.txt"/>
</target>
</project>