Android Studio version 4.1.1
Gradle version 6.5
Android Gradle Plugin Version 4.1.0
Start building my android app and I get:
Starting Gradle Daemon...
Gradle Daemon started in 2 s 29 ms
Starting Gradle Daemon...
Gradle Daemon started in 1 s 965 ms
Starting Gradle Daemon...
Gradle Daemon started in 1 s 996 ms
Starting Gradle Daemon...
Gradle Daemon started in 1 s 992 ms
Starting Gradle Daemon...
Gradle Daemon started in 1 s 995 ms
And everyone of those started a separate virtual machine at about 30mb each and it goes like that until my 16Gb of memory is exhausted. First time it happened I had to cut the power off...
And the VMs and their memory consumption survive shutting down Android Studio. I have to kill the processes by hand. Anybody experienced something similar? How do I fix it? I can't build my project anymore. Trying to disable the gradle daemon by using either the environment or the config file didn't work. I am stuck...
Thank you @Tormond. Your answer may help somebody else as the issue has to do with the network configuration of the computer. I tried it and it didn't help in may case, but checking the log files of the gradle daemon I spotted issues with the network. Didn't really understand what it was all about but I just disabled all but my physical ethernet connection. Then by excluding one by one I found out that the issue is with the "Mobile Hotspot" provided by my computer. So it is NOT the existence of the wireless but the enabling of the Mobile Hotspot. Now, when I want to use gradle I have to disable the Mobile Hotspot - frustrating!
Also very unsettling that after gradle daemon starts all the VM instances that failed are still there using up memory, and the only way to get rid of them is to go and kill them one by one.
Running this solved everything for me (both in AS and CLI):
export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
Then try e.g. ./gradlew assembleDebug
after that, or start another build in AS. Let me know if it helps your case too!
This was what pointed me in the right direction: https://stackoverflow.com/a/28655193/3328701
Update: What actually caused this in the firstplace was that I was sharing wifi through ethernet to another computer, if I turn off wifi sharing I no longer need the workaround (preferIPv4Stack=true).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With