I don't use ubuntu or know the answer but these links seem to be dealing with the same issue:
1) How to fix Android Studio getting stuck executing Gradle tasks?
The solution to this one was to install libz.so.1
and you can find installation instructions here: libz.so.1: cannot open shared object file
2) I can't build project in Android Studio on Ubuntu. Gradle running build takes infinity
The solution to the second one was to use these two commands in Terminal:
sudo dpkg --add-architecture i386
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
3) Android Studio gradle takes too long to build
I'm not sure the third link is as relevant, as it solves the problem of gradle builds taking a long time, not the problem of gradle builds getting stuck, but it still may be helpful information.
The solution to the third link was to go to:
In Android Studio go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Check the 'Offline work' under 'Global Gradle settings'
