Reputation: 1869
Whenever I open or create a project in Android Studio, and it starts to do its background build or whatever, it gets to "Starting Gradle daemon", but gets in a loop and never stops repeating that step. As a result, the build never finishes and it keeps creating Gradle daemon processes until the system runs out of memory and freezes.
This is in Ubuntu. It did work previously, and I don't know what could have changed to make it start happening. Has anyone else run into this problem and been able to fix it?
Upvotes: 23
Views: 8792
Reputation: 3593
for me:
disconnected the real device attached for testing,
which, i use for testing apps as well as for internet connection through tethering.
and hurray.
on more study, found that the loose usb cable was culprit.
Upvotes: 0
Reputation: 2218
TL;DR: Turn off Windows Mobile Hotspot (aka, adHoc Adapter or Wi-Fi Direct Virtual Adapter) before your first build.
For some reason, while the hotspot is on, gradle server cannot accept incoming connections from /127.0.0.1
according to the log file in %userProfile%\.gradle\daemon\<version>\
. And so, it keeps spawning new daemons thinking the old ones (sleeping in wait for connections) are dead.
Every time you need a new gradle daemon (eg. open a new project), you have to turn the hotspot off, wait for AS to connect to the daemon (eg. start building, sync gradle files, etc.), then re-enable it.
Notice that if you forget to disable the hotspot and start a build/sync process, your RAM will be filled with waiting gradle daemons. Kill them all before you try again or you will have an "Insufficient Memory" error.
I use this nice command in a shortcut file to kill all deamons with one click:
C:\Windows\System32\taskkill.exe /F /IM java.exe /T
. Of course this is assuming you have no java processes other than gradle daemons (which is mostly the case when I'm working on AS), and you don't mind working daemons be restarted (which isn't a big deal imo).
This problem started only after upgrading from AS 4.0 to 4.1 and stayed for the next upgrades too.
Upvotes: 48
Reputation: 71
I have same Error on Win 10, I searched a lot but nothing helped me.
restore all firewall settings.
old style Control Panel → System & Safety → Windows Defender → Restore Defaults
Note: options/words may not very similar, because it translated.
Update 1:
is run Build before connect PC to internet, then after Daemon started connect to network, and builds will work fine.
or you can try disabling Daemon, or let it work offline.
I hope this could help someone.
Upvotes: 0
Reputation: 96
I had the same problem on Linux. I traced it down to a firewall misconfiguration. It prevented Android Studio from communicating with Gradle daemon using IP over loopback interface.
Upvotes: 8