I would try JDK v17. I had similar problems when I upgraded to Ladybug in my Capacitor 6 app since Ladybug now defaults to v21.
To downgrade, you have to download v17 via that interface. Make sure it is in a different location than v21. It didn’t work for me in the same location.
Also, after changing the version I had to restart my computer to have it take affect as the Gradle Daemon was caching v21.