aboutsummaryrefslogtreecommitdiffstats
path: root/build.xml
blob: f34e303412f0787d6758fb2085d49ffe99988d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
<?xml version="1.0" encoding="UTF-8"?>
<project name="ConnectBot" default="help">

    <!-- The local.properties file is created and updated by the 'android' tool.
         It contain the path to the SDK. It should *NOT* be checked in in Version
         Control Systems. -->
    <property file="local.properties"/>

    <!-- The build.properties file can be created by you and is never touched
         by the 'android' tool. This is the place to change some of the default property values
         used by the Ant rules.
         Here are some properties you may want to change/update:

         application.package
             the name of your application package as defined in the manifest. Used by the
             'uninstall' rule.
         source.dir
             the name of the source folder. Default is 'src'.
         out.dir
             the name of the output folder. Default is 'bin'.

         Properties related to the SDK location or the project target should be updated
          using the 'android' tool with the 'update' action.

         This file is an integral part of the build system for your application and
         should be checked in in Version Control Systems.

         -->
    <property file="build.properties"/>

    <!-- The default.properties file is created and updated by the 'android' tool, as well
         as ADT.
         This file is an integral part of the build system for your application and
         should be checked in in Version Control Systems. -->
    <property file="default.properties"/>

    <!-- Custom Android task to deal with the project target, and import the proper rules.
         This requires ant 1.6.0 or above. -->
    <path id="android.antlibs">
        <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
        <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
        <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
        <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
        <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
    </path>

    <taskdef name="setup"
        classname="com.android.ant.SetupTask"
        classpathref="android.antlibs" />

    <!-- Execute the Android Setup task that will setup some properties specific to the target,
         and import the rules files.
         To customize the rules, copy/paste them below the task, and disable import by setting
         the import attribute to false:
            <setup import="false" />

         This will ensure that the properties are setup correctly but that your customized
         targets are used.
    -->
    <setup import="false" />

    <!-- Custom tasks -->
    <taskdef name="aaptexec"
        classname="com.android.ant.AaptExecLoopTask"
        classpathref="android.antlibs" />

    <taskdef name="apkbuilder"
        classname="com.android.ant.ApkBuilderTask"
        classpathref="android.antlibs" />

    <taskdef name="xpath"
        classname="com.android.ant.XPathTask"
        classpathref="android.antlibs"/>

    <!-- Properties -->

    <!-- Tells adb which device to target. You can change this from the command line
         by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
         the emulator. -->
    <property name="adb.device.arg" value="" />

    <property name="android.tools.dir" location="${sdk.dir}/tools" />
    <!-- Name of the application package extracted from manifest file -->
    <xpath input="AndroidManifest.xml" expression="/manifest/@package"
                output="manifest.package" />

    <!-- Input directories -->
    <property name="source.dir" value="src" />
    <property name="source.absolute.dir" location="${source.dir}" />
    <property name="gen.dir" value="gen" />
    <property name="gen.absolute.dir" location="${gen.dir}" />
    <property name="resource.dir" value="res" />
    <property name="resource.absolute.dir" location="${resource.dir}" />
    <property name="asset.dir" value="assets" />
    <property name="asset.absolute.dir" location="${asset.dir}" />

    <!-- Directory for the third party java libraries -->
    <property name="external.libs.dir" value="libs" />
    <property name="external.libs.absolute.dir" location="${external.libs.dir}" />

    <!-- Directory for the native libraries -->
    <property name="native.libs.dir" value="libs" />
    <property name="native.libs.absolute.dir" location="${native.libs.dir}" />

    <!-- Output directories -->
    <property name="out.dir" value="bin" />
    <property name="out.absolute.dir" location="${out.dir}" />
    <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
    <property name="out.classes.absolute.dir" location="${out.classes.dir}" />

    <!-- Intermediate files -->
    <property name="dex.file.name" value="classes.dex" />
    <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" />

    <!-- The final package file to generate -->
    <property name="out.debug.unaligned.package"
                  location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />
    <property name="out.debug.package"
                  location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
    <property name="out.unsigned.package"
                  location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" />
    <property name="out.unaligned.package"
                  location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" />
    <property name="out.release.package"
                  location="${out.absolute.dir}/${ant.project.name}-release.apk" />

    <!-- Verbosity -->
    <property name="verbose" value="false" />
    <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
         The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
         value.-->
    <condition property="verbosity" value="verbose" else="quiet">
        <istrue value="${verbose}" />
    </condition>
    <!-- This is needed to switch verbosity of zipalign and aapt. Depends exclusively on 'verbose'
         -->
    <condition property="v.option" value="-v" else="">
        <istrue value="${verbose}" />
    </condition>
    <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' -->
    <condition property="verbose.option" value="--verbose" else="">
        <istrue value="${verbose}" />
    </condition>

    <!-- Tools -->
    <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
    <property name="adb" location="${android.tools.dir}/adb${exe}" />
    <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />

    <!-- Emma configuration -->
    <property name="emma.dir" value="${sdk.dir}/tools/lib" />
        <path id="emma.lib">
            <pathelement location="${emma.dir}/emma.jar" />
            <pathelement location="${emma.dir}/emma_ant.jar" />
        </path>
    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
    <!-- End of emma configuration -->

    <!-- Macros -->

    <!-- Configurable macro, which allows to pass as parameters output directory,
         output dex filename and external libraries to dex (optional) -->
    <macrodef name="dex-helper">
       <element name="external-libs" optional="yes" />
       <element name="extra-parameters" optional="yes" />
       <sequential>
         <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...
         </echo>
         <apply executable="${dx}" failonerror="true" parallel="true">
             <arg value="--dex" />
             <arg value="--output=${intermediate.dex.file}" />
             <extra-parameters />
             <arg line="${verbose.option}" />
             <arg path="${out.classes.absolute.dir}" />
             <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
             <external-libs />
         </apply>
       </sequential>
    </macrodef>

    <!-- This is macro that enable passing variable list of external jar files to ApkBuilder
         Example of use:
         <package-helper>
             <extra-jars>
                <jarfolder path="my_jars" />
                <jarfile path="foo/bar.jar" />
                <jarfolder path="your_jars" />
             </extra-jars>
         </package-helper> -->
    <macrodef name="package-helper">
        <attribute name="sign.package" />
        <element name="extra-jars" optional="yes" />
        <sequential>
            <apkbuilder
                    outfolder="${out.absolute.dir}"
                    basename="${ant.project.name}"
                    signed="@{sign.package}"
                    verbose="${verbose}">
                <file path="${intermediate.dex.file}" />
                <sourcefolder path="${source.absolute.dir}" />
                <nativefolder path="${native.libs.absolute.dir}" />
                <jarfolder path="${external.libs.absolute.dir}" />
                <extra-jars/>
            </apkbuilder>
        </sequential>
    </macrodef>

    <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets
         debug, -debug-with-emma and release.-->
    <macrodef name="zipalign-helper">
        <attribute name="in.package" />
        <attribute name="out.package" />
        <sequential>
            <echo>Running zip align on final apk...</echo>
            <exec executable="${zipalign}" failonerror="true">
                <arg line="${v.option}" />
                <arg value="-f" />
                <arg value="4" />
                <arg path="@{in.package}" />
                <arg path="@{out.package}" />
            </exec>
        </sequential>
    </macrodef>

    <!-- This is macro used only for sharing code among two targets, -install and
         -install-with-emma which do exactly the same but differ in dependencies -->
    <macrodef name="install-helper">
        <sequential>
            <echo>Installing ${out.debug.package} onto default emulator or device...</echo>
            <exec executable="${adb}" failonerror="true">
                <arg line="${adb.device.arg}" />
                <arg value="install" />
                <arg value="-r" />
                <arg path="${out.debug.package}" />
            </exec>
        </sequential>
    </macrodef>

    <!-- Rules -->

    <!-- Creates the output directories if they don't exist yet. -->
    <target name="-dirs">
        <echo>Creating output directories if needed...</echo>
        <mkdir dir="${resource.absolute.dir}" />
        <mkdir dir="${external.libs.absolute.dir}" />
        <mkdir dir="${gen.absolute.dir}" />
        <mkdir dir="${out.absolute.dir}" />
        <mkdir dir="${out.classes.absolute.dir}" />
    </target>

    <!-- Generates the R.java file for this project's resources. -->
    <target name="-resource-src" depends="-dirs, update-version">
        <echo>Generating R.java / Manifest.java from the resources...</echo>
        <exec executable="${aapt}" failonerror="true">
            <arg value="package" />
            <arg line="${v.option}" />
            <arg value="-m" />
            <arg value="-J" />
            <arg path="${gen.absolute.dir}" />
            <arg value="-M" />
            <arg path="AndroidManifest.xml" />
            <arg value="-S" />
            <arg path="${resource.absolute.dir}" />
            <arg value="-I" />
            <arg path="${android.jar}" />
        </exec>
    </target>

    <!-- Generates java classes from .aidl files. -->
    <target name="-aidl" depends="-dirs">
        <echo>Compiling aidl files into Java classes...</echo>
        <apply executable="${aidl}" failonerror="true">
            <arg value="-p${android.aidl}" />
            <arg value="-I${source.absolute.dir}" />
            <arg value="-o${gen.absolute.dir}" />
            <fileset dir="${source.absolute.dir}">
                <include name="**/*.aidl" />
            </fileset>
        </apply>
    </target>

    <!-- Compiles this project's .java files into .class files. -->
    <target name="compile" depends="-resource-src, -aidl"
                description="Compiles project's .java files into .class files">
        <!-- If android rules are used for a test project, its classpath should include
             tested project's location -->
        <condition property="extensible.classpath"
                           value="${tested.project.absolute.dir}/bin/classes" else=".">
            <isset property="tested.project.absolute.dir" />
        </condition>
        <javac encoding="utf8" target="1.5" debug="true" extdirs=""
                destdir="${out.classes.absolute.dir}"
                bootclasspathref="android.target.classpath"
                verbose="${verbose}" classpath="${extensible.classpath}">
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <classpath>
                <fileset dir="${external.libs.dir}" includes="*.jar"/>
            </classpath>
         </javac>
    </target>

    <target name="check-proguard">
        <available file="tools/proguard.jar" property="have.proguard"/>
    </target>

    <target name="proguard" depends="check-proguard">
        <fail unless="have.proguard">You requested ProGuard, but you don't have the JAR available! See README</fail>
    </target>

    <target name="proguard.execute" depends="compile" if="have.proguard">
        <taskdef resource="proguard/ant/task.properties"
                classpath="tools/proguard.jar" />
        <proguard>
            -injars ${out.classes.dir}
            -outjars ${out.dir}/classes.min.jar
            -libraryjars ${android.jar}
            -dontskipnonpubliclibraryclasses
            -dontobfuscate
            -dontoptimize
            -printusage ${out.dir}/proguard.usage

            -keep public class * extends android.app.Activity
            -keep public class * extends android.app.Service
            -keep class org.connectbot.**
            -keep public class com.trilead.ssh2.compression.*
            -keep public class com.trilead.ssh2.crypto.*
        </proguard>
    </target>

    <!-- Convert this project's .class files into .dex files. -->
    <target name="dex.proguard" depends="proguard.execute" if="have.proguard">
        <echo>Converting compiled files and external libraries into ${out.dir}/${dex.file.name}...</echo>
        <apply executable="${dx}" failonerror="true" parallel="true">
            <arg value="--dex" />
            <arg value="--output=${intermediate.dex.file}" />
            <fileset dir="${out.absolute.dir}" includes="*.min.jar" />
            <fileset dir="${external.libs.absolute.dir}" includes="*.jar"/>
        </apply>
    </target>

    <!-- Convert this project's .class files into .dex files. -->
    <target name="dex.vanilla" depends="compile" unless="have.proguard">
        <echo>Converting compiled files and external libraries into ${out.dir}/${dex.file.name}...</echo>
        <apply executable="${dx}" failonerror="true" parallel="true">
            <arg value="--dex" />
            <arg value="--output=${intermediate.dex.file}" />
            <arg path="${out.classes.absolute.dir}" />
            <fileset dir="${external.libs.absolute.dir}" includes="*.jar"/>
        </apply>
    </target>

    <target name="-dex" depends="dex.vanilla, dex.proguard" />

    <!-- Put the project's resources into the output package file
         This actually can create multiple resource package in case
         Some custom apk with specific configuration have been
         declared in default.properties.
         -->
    <target name="-package-resources">
        <echo>Packaging resources</echo>
        <aaptexec executable="${aapt}"
                command="package"
                manifest="AndroidManifest.xml"
                resources="${resource.absolute.dir}"
                assets="${asset.absolute.dir}"
                androidjar="${android.jar}"
                outfolder="${out.absolute.dir}"
                basename="${ant.project.name}" />
    </target>

    <!-- Packages the application and sign it with a debug key. -->
    <target name="-package-debug-sign" depends="-dex, -package-resources">
        <package-helper sign.package="true" />
    </target>

    <!-- Packages the application without signing it. -->
    <target name="-package-no-sign" depends="-dex, -package-resources">
        <package-helper sign.package="false" />
    </target>

    <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again">
       <subant target="compile">
            <fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
       </subant>
    </target>

    <!-- Builds debug output package, provided all the necessary files are already dexed -->
    <target name="debug" depends="-compile-tested-if-test, -package-debug-sign"
                description="Builds the application and signs it with a debug key.">
        <zipalign-helper in.package="${out.debug.unaligned.package}"
                                   out.package="${out.debug.package}" />
        <echo>Debug Package: ${out.debug.package}</echo>
    </target>

    <target name="-release-check">
        <condition property="release.sign">
            <and>
                <isset property="key.store" />
                <isset property="key.alias" />
            </and>
        </condition>
    </target>

    <target name="-release-nosign" depends="-release-check" unless="release.sign">
        <echo>No key.store and key.alias properties found in build.properties.</echo>
        <echo>Please sign ${out.unsigned.package} manually</echo>
        <echo>and run zipalign from the Android SDK tools.</echo>
    </target>

    <target name="release" depends="-package-no-sign, -release-nosign" if="release.sign"
                description="Builds the application. The generated apk file must be signed before
                            it is published.">
        <!-- Gets passwords -->
        <input
                message="Please enter keystore password (store:${key.store}):"
                addproperty="key.store.password" />
        <input
                message="Please enter password for alias '${key.alias}':"
                addproperty="key.alias.password" />

        <!-- Signs the APK -->
        <echo>Signing final apk...</echo>
        <signjar
                jar="${out.unsigned.package}"
                signedjar="${out.unaligned.package}"
                keystore="${key.store}"
                storepass="${key.store.password}"
                alias="${key.alias}"
                keypass="${key.alias.password}"
                verbose="${verbose}" />

        <!-- Zip aligns the APK -->
        <zipalign-helper in.package="${out.unaligned.package}"
                                   out.package="${out.release.package}" />
        <echo>Release Package: ${out.release.package}</echo>
    </target>

    <target name="install" depends="debug"
                description="Installs/reinstalls the debug package onto a running
                            emulator or device. If the application was previously installed,
                            the signatures must match." >
        <install-helper />
    </target>

    <target name="-uninstall-check">
        <condition property="uninstall.run">
           <isset property="manifest.package" />
        </condition>
    </target>
    <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run">
        <echo>Unable to run 'ant uninstall', manifest.package property is not defined.
        </echo>
    </target>

    <!-- Uninstalls the package from the default emulator/device -->
    <target name="uninstall" depends="-uninstall-error" if="uninstall.run"
                description="Uninstalls the application from a running emulator or device.">
        <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo>
        <exec executable="${adb}" failonerror="true">
            <arg line="${adb.device.arg}" />
            <arg value="uninstall" />
            <arg value="${manifest.package}" />
        </exec>
    </target>

    <!-- Targets for code-coverage measurement purposes, invoked from external file -->

    <!-- Emma-instruments tested project classes (compiles the tested project if necessary)
             and writes instrumented classes to ${instrumentation.absolute.dir}/classes -->
    <target name="-emma-instrument" depends="compile">
        <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
        <!-- It only instruments class files, not any external libs -->
        <emma enabled="true">
            <instr verbosity="${verbosity}"
                   mode="overwrite"
                   instrpath="${out.absolute.dir}/classes"
                   outdir="${out.absolute.dir}/classes">
            </instr>
            <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
                 user defined file -->
        </emma>
    </target>

    <target name="-dex-instrumented" depends="-emma-instrument">
       <dex-helper>
          <extra-parameters>
            <arg value="--no-locals" />
          </extra-parameters>
          <external-libs>
            <fileset file="${emma.dir}/emma_device.jar" />
          </external-libs>
       </dex-helper>
    </target>

    <!-- Invoked from external files for code coverage purposes -->
    <target name="-package-with-emma" depends="-dex-instrumented, -package-resources">
        <package-helper sign.package="true">
            <extra-jars>
                <!-- Injected from external file -->
                <jarfile path="${emma.dir}/emma_device.jar" />
            </extra-jars>
        </package-helper>
    </target>

    <target name="-debug-with-emma" depends="-package-with-emma">
        <zipalign-helper in.package="${out.debug.unaligned.package}"
                                   out.package="${out.debug.package}" />
    </target>

    <target name="-install-with-emma" depends="-debug-with-emma">
        <install-helper />
    </target>

    <!-- End of targets for code-coverage measurement purposes -->

    <target name="help">
        <!-- displays starts at col 13
              |13                                                              80| -->
        <echo>Android Ant Build. Available targets:</echo>
        <echo>   help:      Displays this help.</echo>
        <echo>   clean:     Removes output files created by other targets.</echo>
        <echo>   compile:   Compiles project's .java files into .class files.</echo>
        <echo>   debug:     Builds the application and signs it with a debug key.</echo>
        <echo>   release:   Builds the application. The generated apk file must be</echo>
        <echo>              signed before it is published.</echo>
        <echo>   install:   Installs/reinstalls the debug package onto a running</echo>
        <echo>              emulator or device.</echo>
        <echo>              If the application was previously installed, the</echo>
        <echo>              signatures must match.</echo>
        <echo>   uninstall: Uninstalls the application from a running emulator or</echo>
        <echo>              device.</echo>
        <echo>   proguard:  use before build statements like "debug" and "release"</echo>
        <echo>              to enable proguard dead code removal. NOTE: You must</echo>
        <echo>              have tools/proguard.jar available. See the README.</echo>
    </target>

    <target name="update-version" description="Updates the Version.java file with current Git revision">
        <echo>Updating resources with Git revision and build date...</echo>

        <tstamp>
            <format property="build.date" pattern="yyyy.MM.dd" />
        </tstamp>

        <!-- Get the version name from the android manifest, will en up in property ${manifest.android:versionName} -->
        <xpath input="AndroidManifest.xml" expression="/manifest/@android:versionName"
                    output="manifest.version.name" />

        <!-- checkout notrans.xml so we can ignore it in our index -->
        <exec executable="git">
            <arg line="checkout res/values/notrans.xml"/>
        </exec>

        <!-- find out the description of the current Git commit -->
        <exec executable="git" outputproperty="git.revision">
            <arg line="describe --match 'v[0-9]*' --dirty"/>
        </exec>

        <replaceregexp file="${resource.absolute.dir}/values/notrans.xml" encoding="utf8" match='(\x3Cstring name="msg_version">)[^\x3C]*(\x3C/string>)'
            replace='\1${ant.project.name} ${manifest.version.name} (${git.revision} ${build.date})\2' />

        <echo>Updated "msg_version" to: ${ant.project.name} ${manifest.version.name} (${git.revision} ${build.date})</echo>
    </target>

    <target name="clean"
        description="Clean up the result of the build process">
        <delete dir="${out.absolute.dir}"/>
        <delete dir="${gen.absolute.dir}"/>
        <exec executable="ant" failonerror="true">
            <arg value="-f" />
            <arg value="tests/build.xml" />
            <arg value="clean"/>
        </exec>
    </target>

    <target name="tests" depends="install">
        <echo>Building and installing tests...</echo>
        <exec executable="ant" failonerror="true">
            <arg value="-f" />
            <arg value="tests/build.xml" />
            <arg value="install"/>
        </exec>
        <echo>Running test cases...</echo>
        <exec executable="${adb}">
            <arg value="shell" />
            <arg value="am" />
            <arg value="instrument" />
            <arg value="-w" />
            <arg value="${application-package}.tests/android.test.InstrumentationTestRunner" />
            <redirector outputproperty="test.results"/>
        </exec>
        <fail message="Some unit tests failed:${line.separator}${test.results}">
            <condition>
                <contains string="${test.results}" substring="FAILURES"/>
            </condition>
        </fail>
    </target>
</project>