您好,我正在使用 vscode 构建 flutter apk,但出现以下错误,请提供有关如何进行操作的任何帮助。进行了研究,但没有得到解决方案。我已经在 android studio 的 gradle 设置中很好地配置了 JAVA_HOME 但 gradle 仍然遇到相同的错误
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html
Process command line: C:\Program Files\Android\Android Studio\jre\bin\java.exe --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx1536M -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\cs\.gradle\wrapper\dists\gradle-6.5-all\2oz4ud9k3tuxjg84bbf55q0tn\gradle-6.5\lib\gradle-launcher-6.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.5
Please read the following process output to find out more:
FAILURE: Build failed with an exception.
* What went wrong:
java.net.BindException: Address already in use: Cannot bind
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.UncheckedIOException: java.net.BindException: Address already in use: Cannot bind
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.cache.internal.locklistener.FileLockCommunicator.<init>(FileLockCommunicator.java:51)
at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.getCommunicator(DefaultFileLockContentionHandler.java:263)
at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.reservePort(DefaultFileLockContentionHandler.java:255)
at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:108)
at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:95)
at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:90)
at org.gradle.cache.internal.OnDemandFileAccess.updateFile(OnDemandFileAccess.java:51)
at org.gradle.cache.internal.SimpleStateCache.update(SimpleStateCache.java:87)
* Get more help at https://help.gradle.org
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
那是因为您在设备中的热点处于活动状态时开始调试 您需要做的就是:
alt+ctrl+delete
什么对我有用
Windows
;
Ctrl+Alt+Delete
)。openJDKs
(与任何 java.exe
一样)。Gradle
即可完成!对我来说效果很好。我在我的 Windows 电脑中禁用了移动热点,然后尝试构建它对我来说不起作用。 然后我刚刚退出并登录再次尝试构建,它成功了!
当你查看任务管理器时,有许多打开的JDK平台二进制文件同时打开并运行,我建议你重新启动你的笔记本电脑,它就会恢复正常。我向你推荐这个,因为这对我来说很有效。
在 Windows 中打开任务管理器
Ctrl + Alt + Supr
,然后结束 adb.exe
的任务。
这对我有用
对我来说,这个问题与活跃的 VPN 连接有关。禁用 VPN 为我解决了这个问题。
1:只需从笔记本电脑和移动应用程序中关闭互联网连接即可。
2:然后关闭 Android Studio 项目并重新打开,这对我有用。
当我的 Windows 10 Pro 22H2 上本周第二次出现该问题时,上述方法均无法解决该问题。
我尝试停用蓝牙、Wi-Fi、VPN、终止 adb.exe 以及任何 Java 或 JDK 进程。我也尝试重新启动计算机,但这些操作都没有解决问题。
但是,我按照此处列出的步骤找到了一个适合我的解决方案:
问题1 如果 6942 到 6991 之间的所有 50 个端口都被保留,被其他应用程序占用或防火墙不允许 IDE 绑定它们,则启动会失败,并出现以下异常:
解决方法:在管理员控制台 (cmd.exe) 中运行以下命令:
netsh int ipv4 set dynamicport tcp start=49152 num=16383
netsh int ipv4 set dynamicport udp start=49152 num=16383
如果上述方法没有帮助,请尝试以下命令:
net stop winnat
net start winnat
对于出现“无法分配请求的地址”错误的 macOS 用户:
请参阅https://apple.stackexchange.com/questions/332407/how-to-change-ifconfig-lo0,此命令应该有所帮助:
sudo ifconfig lo0 alias 127.0.0.1
例外:
java.util.concurrent.CompletionException: java.net.BindException: Address already in use: bind
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
... 1 more
-----
JRE 11.0.6+8-b765.25 amd64 by JetBrains s.r.o
C:\Users\yatwi\AppData\Local\JetBrains\Toolbox\apps\Rider\ch-0\201.6668.197\jbr
问题2 由于防火墙/VPN,无法在网络受限的情况下启动 IDE:例如,请参阅 IDEA-253939。
解决方法 将
-Djava.net.preferIPv4Stack=true
添加到 IDE 的 .vmoptions
文件并启动 IDE。
在此处查看 .vmoptions
文件:https://intellij-support.jetbrains.com/hc/en-us/articles/206544869 .
例外:
java.util.concurrent.CompletionException: java.lang.IllegalStateException: failed to create a child event loop
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: failed to create a child event loop
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:88)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:58)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:47)
at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:59)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:86)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:81)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:68)
at org.jetbrains.io.BuiltInServerKt.multiThreadEventLoopGroup(BuiltInServer.kt:144)
at org.jetbrains.io.BuiltInServerKt.access$multiThreadEventLoopGroup(BuiltInServer.kt:1)
at org.jetbrains.io.BuiltInServer$Companion.start(BuiltInServer.kt:54)
at org.jetbrains.io.BuiltInServer.start(BuiltInServer.kt)
at com.intellij.idea.SocketLock.lambda$lockAndTryActivate$2(SocketLock.java:171)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
... 7 more
Caused by: io.netty.channel.ChannelException: failed to open a new selector
at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:175)
at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:142)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:146)
at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:37)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:84)
... 19 more
Caused by: java.io.IOException: Unable to establish loopback connection
at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:94)
at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:61)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/sun.nio.ch.PipeImpl.<init>(PipeImpl.java:171)
at java.base/sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50)
at java.base/java.nio.channels.Pipe.open(Pipe.java:155)
at java.base/sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:142)
at java.base/sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:44)
at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:173)
... 23 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:476)
at java.base/sun.nio.ch.Net.connect(Net.java:468)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:694)
at java.base/java.nio.channels.SocketChannel.open(SocketChannel.java:194)
at java.base/sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(PipeImpl.java:127)
at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:76)
... 31 more
-----
JRE 11.0.8+10-b1129.2 amd64 by JetBrains s.r.o.
C:\Program Files\JetBrains\IntelliJ IDEA 203.5251.39\jbr
或者是最后一部分的
Caused by: java.net.SocketException: Permission denied: connect
造成的。