Reputation: 1219
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.
Upvotes: 57
Views: 129449
Reputation: 60
May be it's bad way, but start studio with sudo nice --17 IDE name seems worked for me
Upvotes: 0
Reputation: 579
Resolution for Gradle stuck using Android Studio version 4.2.2:
When the resources are downloaded successfully the Android Studio should be restarted with "Invalidate cache and restart" and offline Gradle mode should be activated before platform-tools indexing.
Upvotes: 0
Reputation: 29150
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 gradle.properties
in the following directory:
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
Add this line to the file:
org.gradle.daemon=true
org.gradle.parallel=true
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 -> Build 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 'com.google.android.gms:play-services:8.3.0'
Only use those Google APIs that your app is really using. If all you are using is Google Maps, you would use this:
com.google.android.gms:play-services-maps:8.3.0
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:
https://developers.google.com/android/guides/setup
Arun George has commented the following solution.
the issue was due to certain 32 bit libraries missing. Had to do
sudo apt-get install lib32z1
. Adding to gradle.properties helped reduce the build time.
Upvotes: 100
Reputation: 736
I have tried all solution. Nothing has worked. So I just restarted my PC and its working fine. You can try it.
Upvotes: 4
Reputation: 1310
You're probably behind the proxy, you might have recently changed your password or something has changed. Go to
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
in gradle.properties file, delete/ change proxy settings. They are different to your android studio proxy settings.
Had the same issue, gradle used to take an hour to build. After I deleted proxy settings from gragle.properties file, it now takes couple seconds.
Upvotes: 1
Reputation: 497
The issue is that the project isn't synced with the gradle files. The resolution I did was go to File > Sync Project with Gradle Files
and it was able to sync.
Upvotes: 7
Reputation: 341
For my case I had to install gcc-multilib
$ sudo apt-get install gcc-multilib
Check the Gradle Console at the bottom right as it has more output than the Event log.
Upvotes: 3
Reputation: 2136
Adding more to @SkyWalker's answer:
Also check if you have the latest version of gradle. Updating gradle plug-in to the latest version could help.
Note: I have a similar setup(Android Studio 2.1 on Ubuntu 16.04), and I had a similar problem. Updating gradle to the latest version solved the problem for me.
Upvotes: 0