2012-11-17 126 views
2

我正在嘗試創建android UI測試。 我按照此鏈接中的示例:http://developer.android.com/tools/testing/testing_ui.html#runningAndroid ant構建項目失敗

請注意,在「構建和部署您的uiautomator測試」階段,出現錯誤,第一個命令必須是/ tools/android 創建 uitest-project -n -t 1 -p。無論如何,這不是我的問題。

我萬阿英,蔣達清在步驟「Ant構建」,我得到這個錯誤:

-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 

你的幫助是非常讚賞。

+0

你可以發佈一個build.xml嗎? – Gorets

回答

-1

確保Apache Ant的軟件必須安裝和ant.exe文件的路徑應該在PATH varable放置

0

回答這裏:Adding external jars to an Android UIautomator project

請使用由neeraj給定t的custom_rules.xml文件(一個editted版本如下)。

neeraj t的最後回答已經爲我工作。我需要做的唯一更新是:將jar添加到libs而不是'lib'文件夾中,並將custom_rule.xml命名爲custom_rules.xml,並將所有內容放在項目中,如下所示(我也在原始解決方案上發佈了編輯)

<?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> 
0

我得到了同樣的錯誤。我所做的錯誤是: 我設置的路徑只能做到在我的項目是目錄(以前一個步驟) 有xyz/projects/Tests

錯誤:給路徑爲:xyz/project

修正路徑:xyz/projects/Tests