Running UIAutomator tests with external libs giving uiautomator java.lang.IllegalAccessError: ref class in pre-checked class

I ran into "java.lang.IllegalAccessError: ref class in pre-checked class ..." while executing UIAutomator tests via command line.

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

I have rewritten below compilation and dex available at

% ANDROID_HOME% \ tools \ ant \ uibuild.xml

to compile the original test code with external libraries and it was successfully able to create a .dex file and a .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 with adb using command

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

and run the command

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

appears below error.

INSTRUMENTATION_RESULT: shortMsg = java.lang.IllegalAccessError INSTRUMENTATION_RESULT: longMsg = ref class in pre-checked class allowed for unexpected implementation INSTRUMENTATION_CODE: 0

Thanks for helping me solve this problem.

+3


source to share





All Articles