Android Studio Gradle Error - Protocol Family Unav

2019-01-26 13:24发布

问题:

So I am relatively new to Android dev. and have been getting Android Studio set up on my computers. I have it set up just fine on my Mac. When I downloaded and installed it on my Windows 8.1 desktop the gradle build seems to fail every time. With an error message stating that the Protocol Family Unavailable. I've tried several things including uninstalling and reinstalling Android Studio.

NOTE: I did try what was said to work here Gradle project refresh failed - Protocol family unavailable yet it did not solve the problem for me.

回答1:

I also had this problem and the referenced thread also didn't work for me.

What did work was setting _JAVA_OPTIONS environment variable to make Java use IPv4.

_JAVA_OPTIONS = -Djava.net.preferIPv4Stack=true

Note that Android Studio sets this variable in the vmoptions file. But for some reason, it isn't used by the Java VM started by Android Studio to run Gradle daemon.

After I did that, everything started to work ok and Gradle could build my project.

I hope it helps.



回答2:

I run into this problem when my firewall blocked studio64.exe from connecting to the internet. I fixed it by granting access.



回答3:

When i use Stunnel i faced this problem and when i disconnected it problem solved .

Check having any Stunnel Vpn or Proxy connection and if you have disconnect it .



回答4:

You could try to fix it temporarily by disabling your anti-virus software while using Android Studio. I'm not entirely sure it will work, but it's worth a try, it worked for me, though I'm aware-, and agree with that this is far from a permanent fix, but it might be good enough while waiting for a fix from the Android Studio team, at least it will let you keep working!

Hope this helps!



回答5:

"Run command prompt as administrator - type cmd in the 'search programs and files' text box in the Windows Start menu; right-click and select 'Run as administrator'.

At the command prompt, type

netsh winsock reset

Restart your PC

This worked for me."

I found it in

Android studio "Cannot start internal HTTP server"



回答6:

This answer is same as first answer in this topic, means first answer is true and works well, but my answer is in detail, i did not set that variable, just turn off proxy.

This error arises due to proxifier running that basically tunnels the computer in ipv6 which is not supported by daemon.

So to overcome this and build project either close the proxifier application from system tray or add the environment variable

_JAVA_OPTIONS= -http://Djava.net.preferIPv4Stack=true



回答7:

I solved same problem by disabling antivirus.