Search code examples
appiumappium-androidappium-iospage-factory

NoSuchMethodException with PageFactory in Appium


While using some code like the following:

PageFactory.initElements(AppiumFieldDecorator(driver, Duration.ofSeconds(3)), this)

I receive this error:

java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup()

You can read the complete error log here.

I found someone else who had this problem, and the only answer is to use JDK 15 instead of JDK 16. I tried, with JDK 15.0.2 and JDK 1.8, but it doesn't solve the problem for me. In addition I would like to continue using JDK 16.

I'm currently using OpenJDK 16.0.2 and Appium 7.5.1.

Do you know how can I solve it?


Solution

  • I tried again with JDK 15.0.2, and it works now: unfortunately I don't know exactly why.

    The following is the init I used in my class:

    PageFactory.initElements(AppiumFieldDecorator(driver), this)