Error when trying to build realm-js from source

I have followed the instructions here on building Realm from source:
But when I run ./gradlew publishAndroid to create the build, it fails with a quite unhelpful message, and therefore I have no idea how to fix it.

Here’s the log:
There’s an error line 214 saying cannot open crtbegin_so.o: No such file or directory, but I don’t know what to make of it.

Thanks in advance.