How to automate build in gradle?

I’m not sure what you are trying to synchronize? What errors are shown by the sync task?

I’m not an Android developer, so unfortunately I’m not familiar with its Gradle plugins.