automationappiumpom.xmlappium-androidpage-factory

Appium - Getting a java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() at PageFactory


I am getting this exception on running an Appium test. The test fails at PageFactory with the exception below.

My POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0`
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.telepathy.test</groupId>
    <artifactId>twitter</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>7.2.0</version>
        </dependency>
    </dependencies>

</project>

Fails here: PageFactory.initElements(new AppiumFieldDecorator(this.driver), this);

java.lang.RuntimeException: java.lang.NoSuchMethodException: 
    jdk.proxy2.$Proxy9.proxyClassLookup()
    at  ​io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(
ApiumByBuilder.java:84)

Solution

  • Check the version of Java you are using. I downgraded from JDK v16 to v15.0.2 and that fixed the problem.