Stuck with Gradle Build Running
Actually it is not stuck. It takes more time to build. I have got almost 3 solutions that can fix the issue.
Solution-1:
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
Solution-2:
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.
Solution-3
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
Resource Link:
- Android Studio gradle takes too long to build
- Discussion about stuck in gradle build
Solution#4:
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.
Android Studio gradle takes too long to build
Found the reason!! 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.
Removing proxy: File > Settings > Appearance & Behavior > System settings > HTTP Proxy
How to fix Android Studio getting stuck executing Gradle tasks?
Fixed it by going to Android Studio
-> Preferences
-> Gradle
-> and ticking Offline work
. Still have no idea what was wrong, but at least now it compiles.
Edit:
In new Android Studio Versions the path is File
-> Other Settings
-> Default Settings
-> Build-Excecution-Deployment
-> Gradle
Android Studio 2.3.3 stuck on Gradle Build Running
This works for me:
CTRL + SHIFT + ESC -> Process -> Kill java.exe -> Rebuild
Related Topics
Adding Spinner to Actionbar (Not Navigation
Detecting The Scrolling Direction in The Adapter (Up/Down)
Does Android Studio Have a Hierarchy Viewer or Layout Inspector
Android Wsdl/Soap Service Client
Google Map for Android My Location Custom Button
Android Studio Could Not Find Any Version That Matches Com.Android.Support:Appcompat-V7:+
How to Get Pid of Android Application Without Using Adb Shell
How to Change System Navigation Bar Color
How to Get Md5 from Debug.Keystore File
Easier Way to Get View's Id (String) by Its Id (Int)
How to Call a Wcf Service Using Ksoap2 on Android
How to Store Files Generated from App in "Downloads" Folder of Android
Android Understanding Heap Sizes
How to Check Which Current Image Resource Is Attached to Imageview in Android Xml
How to Click on an Item Inside a Recyclerview in Espresso