Arun George Arun George - 1 year ago 185
Android Question

Stuck with Gradle Build Running

While trying to build my Application on Android Studio 2.1 (On Ubuntu 16.04), it gets stuck on the below note:

Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

Can anybody please help me out.

Answer Source

Actually it is not stuck. It takes more time to build. I have got almost 3 solutions that can fix the issue.


Following the steps will make it 10 times faster and reduce build time 90%

First create a file named in the following directory:

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

Add this line to the file:




If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build, probably its trying to reach the proxy server and waiting for a timeout. When I removed the proxy server setting its working fine.

In Android Studio go to File -> Settings -> Build, Execution, Deployment -> Buil Tools -> Gradle

Check the 'Offline work' under 'Global Gradle settings'

It will reduce 90% gradle build time.


If you are using Google Play services, make sure you aren't using this in your Gradle build script:

compile ''

Only use those Google APIs that your app is really using. If all you are using is Google Maps, you would use this:

When I did this, my compile time went from over 2 minutes to around 25 seconds. For a list of the Google apis that you can selectively compile against, see:

Resource Link:

  1. Android Studio gradle takes too long to build
  2. Discussion about stuck in gradle build
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download