13

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kerbstomp
  • 164
  • 1
  • 1
  • 11
  • see this https://stackoverflow.com/questions/19889503/android-studio-cannot-start-internal-http-server it solved this problem for me. – Mohammad Roshani Mar 12 '18 at 05:05

9 Answers9

14

When I used Stunnel I faced this problem and my problem was solved when I disconnented it.

‌check it and if you have any Stunnel, Vpn or Proxy running in your system , disconnect it first and try again.

SAYE
  • 1,247
  • 2
  • 20
  • 47
11

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.

Francisco Junior
  • 1,986
  • 18
  • 25
  • 2
    Spent 3 days trying to get a brand new installation of Android Studio 1.5.1 to work. Gradle sync was failing even for a new project with "An established connection was aborted by the software in your host machine". On a whim I tried doing a clean of the project and got the "Protocol family unavailable" error which eventually led me to this answer which solved my problem. – Jim Rhodes Feb 04 '16 at 19:30
  • Worked for me with Android Studio 2.0 beta 2 – Behrouz.M Feb 15 '16 at 17:15
  • @francisco-junior which file must be paste this code? after setting that to `studio64.vmoptions` i get error on running AS – DolDurma Apr 06 '18 at 07:56
  • 1
    Hi, @Mahdi.Pishguy. You have to add it to your system's environment variables. – Francisco Junior Apr 07 '18 at 01:35
  • I have edited the Windows 10 system environment, I tried both _JAVA_OPTIONS abd JAVA_TOOL_OPTIONS without lucjk (new error). The only workaround is to stop Avast firewall. – Leos Literak Aug 04 '19 at 09:46
  • Using the Kerio Maker VPN and the selected service tunnel type was set to STunnel, I switched that type into Cisco AnyConnect and the problem solved. – Alireza Kazemi Jun 24 '21 at 09:43
4

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

Terel
  • 3,857
  • 1
  • 25
  • 28
1

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!

Daniel Kvist
  • 3,032
  • 5
  • 26
  • 51
1

"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"

Mohammad Roshani
  • 486
  • 7
  • 19
  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes – Ram Koti Mar 12 '18 at 05:30
1

My problem was using a VPN on an per-app basis connection mode while Android Studio was blocked.

Sdghasemi
  • 5,370
  • 1
  • 34
  • 42
0

I solved same problem by disabling antivirus.

Stanislav Machel
  • 349
  • 2
  • 20
0

for me proxifire.exe was running in background and cause to connection problem, after closing problem gone

Vahid
  • 1,588
  • 4
  • 22
  • 34
-1

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

mortezahosseini
  • 167
  • 1
  • 13