I realized the issue was happening due to the incorrect jdk version being installed. I completely uninstalled java from my computer <https://www.java.com/en/download/help/mac_uninstall_java.html> along with the jdk <https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#uninstall>. Then installed jdk 21 (jdk 24 is not compatible with kotlin) and the build succeeded