I am facing "java.lang.IllegalAccessError: Class ref in pre-verified class... " while running the UIAutomator tests through command prompt .

I created a uiautomator test project and added external apache-commons-lang.jar to the test project/libs folder .

I have the overwritten below compile and dex target which is available at the location

%ANDROID_HOME%\tools\ant\uibuild.xml

to compile the source test code with external libs and it successfully able to create the .dex file and the .jar file .

<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="uiautomator.jar" />
        <include name="commons-lang-2.0.jar" />
    </fileset>
</path>


<target name="compile" depends="-build-setup, -pre-compile">
    <echo message="In the compilation****"/>
    <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>

<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="*.jar" />
        </fileset>
        <path path="${out.classes.absolute.dir}" />
    </dex>
</target>

But after pushing the jar file through adb using the command

adb push test-project.jar /data/local/tmp/

and running the command

adb shell uiautomator runtest /data/local/tmp/test-project.jar -c package-name.TestClass

results below error.

INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalAccessError INSTRUMENTATION_RESULT: longMsg=Class ref in pre-verified class resolved to unexpected implementation INSTRUMENTATION_CODE: 0

Advanced thanks for any help to resolve this .

0

There are 0 answers