Broken pipe. The Gradle daemon may be trying to use ipv4 instead of ipv6.

编译报错

Broken pipe.
The Gradle daemon may be trying to use ipv4 instead of ipv6.

官网方案

Gradle Sync Failed: Broken Pipe
The issue is that the Gradle daemon is trying to use IPv4 instead of IPv6.

解决方案一(部分设备无用)

Workaround 1: On Linux, put the following in your ~/.profile or ~/.bash_profile:
export _JAVA_OPTIONS=“-Djava.net.preferIPv6Addresses=true”

解决方案二(常用方案)

Workaround 2: in Android Studio’s vmoptions file, change the line -Djava.net.preferIPv4Addresses=true to -Djava.net.preferIPv6Addresses=true For more information, see the Networking IPv6 User Guide.

方案二 文件地址

Windows

C:\Users\YourUserName\AppData[Local|Roaming]\Google\AndroidStudio4.2\studio64.exe.vmoptions

macOS

~/Library/Application Support/Google/AndroidStudio4.2/studio.vmoptions

Linux

~/.config/Google/AndroidStudio4.2/studio64.vmoptions

If Studio still doesn’t start after trying this workaround, see Studio doesn’t start after upgrade below.

你可能感兴趣的:(android)