简体   繁体   中英

Android ant build project failure

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.

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> 

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

确保必须安装Apache ant软件,并且ant.exe文件的路径应放置在PATH变量中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM