2

I am trying to create android UI test. I have followed the example in this link: http://developer.android.com/tools/testing/testing_ui.html#running.

Note that in phase "Building and Deploying Your uiautomator Tests", there is a mistake, the first command must be /tools/android create uitest-project -n -t 1 -p . Anyway, this is not my problem.

My probelm is in step "ant build", I am getting this error:

-post-compile:

-dex:
      [dex] input: c:\Users\tabony\workspace\bin\classes
      [dex] Converting compiled files and external libraries into c:\Users\tabony\workspace\bin\classes.dex...
      [dx] no classfiles specified

BUILD FAILED
    c:\Program Files (x86)\Android\android-sdk\tools\ant\ **uibuild.xml:197: null returned: 1**

Total time: 1 second

Your help is much appreciated.

MrEngineer13
  • 38,642
  • 13
  • 74
  • 93
Amir
  • 129
  • 8

3 Answers3

0

answered here: Adding external jars to an Android UIautomator project

please use the custom_rules.xml files given by neeraj t(an editted version given below).

The last answer by neeraj t has worked for me. The only updates I needed to do are: putting jars in libs not 'lib' folder and naming the custom_rule.xml into custom_rules.xml and put everything inside project as shown below (I have posted an edit on the original solution too)

   <?xml version="1.0" encoding="UTF-8"?>
    <project name="custom_rules">

<property name="jar.libs.dir" value="libs" />
<property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
<path id="classpath">
    <fileset dir="${jar.libs.absolute.dir}">
        <include name="your-helping-version.jar" />
        <include name="gson-2.2.2.jar" />
    </fileset>
</path>

<!-- version-tag: VERSION_TAG -->
<import file="${sdk.dir}/tools/ant/uibuild.xml" />


<!-- overwrite the compile target in uibuild.xml to include to external 
    jars -->
<target name="compile" depends="-build-setup, -pre-compile">
    <javac encoding="${java.encoding}" source="${java.source}"
        target="${java.target}" debug="true" extdirs="" includeantruntime="false"
        destdir="${out.classes.absolute.dir}" bootclasspathref="project.target.class.path"
        verbose="${verbose}" fork="${need.javac.fork}">
        <src path="${source.absolute.dir}" />
        <classpath refid="classpath" />
        <compilerarg line="${java.compilerargs}" />
    </javac>
</target>

<!-- overwrite the -dex target in uibuild.xml to include external jar files 
    into the target dex file. -->
<target name="-dex" depends="compile, -post-compile">
    <dex executable="${dx}" output="${intermediate.dex.file}"
        nolocals="@{nolocals}" verbose="${verbose}">
        <fileset dir="${jar.libs.absolute.dir}">
            <include name="your-helping-version.jar" />
            <include name="gson-2.2.2.jar" /> 
        </fileset>
        <path path="${out.classes.absolute.dir}" />
    </dex>
</target>
</project> 
Community
  • 1
  • 1
Beky
  • 1
0

I was getting the same error. The error i made was: i set the path only till the directory where my project was.(one step previously) had xyz/projects/Tests

error: gave path as: xyz/project

corrected path: xyz/projects/Tests

Lavekush Agrawal
  • 6,040
  • 7
  • 52
  • 85
Deepak Negi
  • 893
  • 10
  • 19
-1

Make sure Apache ant software must be installed and path of ant.exe file should place in PATH varable

Dennis Mathew
  • 408
  • 5
  • 14