-1

I'm just starting out with Android Studio and was very frustrated for a while because I couldn't get anything, not even the template project to build. The log kept saying "Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection. Consult IDE log for more details (Help | Show Log)"

Turns out, the root of the problem is that when the gradle daemon started, it immediately died because my DNS settings prevented java from establishing a loopback connection. Setting -Djava.net.preferIPv4Stack=true fixes the problem and now I can start gradle standalone and run builds with it, but how do I get Android Studio to do that?

Piyush
  • 2,589
  • 6
  • 38
  • 77

2 Answers2

1

I fixed this by removing a masquerade rule from my postrouting NAT table.

[root@me]: iptables -t nat -L
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere
[root@me]: iptables -t nat -D POSTROUTING 1

I still have other MASQUERADING rules in that table but they have specific source address masks rather than source "anywhere".

Dan Brough
  • 2,745
  • 1
  • 24
  • 24
0

The Solution Worked for me

1.Open the projects gradle.properties file in your IDE android studio

2.Add this line at end of file org.gradle.jvmargs=-Xmx1024m & Save the file

3.Close & reopen the project is Mandatory.

also refer link1 and link2 for your prefrence

Community
  • 1
  • 1
vijay chhalotre
  • 396
  • 2
  • 11
  • Sorry for the late reply, I've been trying this in other ways. Unfortunately, this does not work, and the gradle logs are still throwing the can't establish loopback connection errors. Any other suggestions? – khasquakhas Mar 10 '17 at 04:17