簡體   English   中英

使用ant與庫項目R18的Android單元測試

[英]Android unit test using ant with library project R18

我遇到了與此問題相同的問題: 使用ant與庫項目進行Android單元測試

我嘗試了問題中提出的兩種方法,但是在Android工具的r18版本中,我得到了:

NTServicesTest/build.xml:110: Reference jar.libs.ref not found. 

我不確定是不是我沒有按照原始問題的答案的解決方法的配方,或者如果在Android工具的r18中發生了某些變化。

我的文件夾設置在包含..的proj文件夾中:

NTServices,NTServicesTest,NTServicesTestApp

對於@Snicolas的解決方法,我修改了我的NTServicesTest / project.properties,如下所示:

# Project target.
target=android-15
tested.android.library.reference.1=../NTServices

我的NTServicesTest / build.xml看起來像這樣:(從版本標簽的右下方)

 <import file="${sdk.dir}/tools/ant/build.xml" />


    <!-- override "compile" target in platform android_rules.xml to include tested app's external libraries -->
 <!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
    <!-- 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>
    <condition property="extensible.libs.classpath"
            value="${tested.project.absolute.dir}/${jar.libs.dir}"
            else="${jar.libs.dir}">
        <isset property="tested.project.absolute.dir" />
    </condition>
    <echo message="jar libs dir : ${tested.project.target.project.libraries.jars}"/>
    <javac encoding="${java.encoding}"
            source="${java.source}" target="${java.target}"
            debug="true" extdirs="" includeantruntime="false"
            destdir="${out.classes.absolute.dir}"
            bootclasspathref="android.target.classpath"
            verbose="${verbose}"
            classpath="${extensible.classpath}"
            classpathref="jar.libs.ref">
        <src path="${source.absolute.dir}" />
        <src path="${gen.absolute.dir}" />
        <classpath>
            <!-- steff: we changed one line here !-->
            <fileset dir="${tested.android.library.reference.1}/bin/" includes="*.jar"/>
            <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
        </classpath>
        <compilerarg line="${java.compilerargs}" />
    </javac>
           <!-- if the project is instrumented, intrument the classes -->
                    <if condition="${build.is.instrumented}">
                        <then>
                            <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>
                        </then>
                    </if>           
</do-only-if-manifest-hasCode>
</target>

只需將classpathref =“jar.libs.ref”重命名為classpathref =“project.libraries.jars”。

是的,它有效。 在R18中,這個屬性改變為project.libraries.jars但是在強制任務中我們沒有改變這個值

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM