Flutter 初学使用过程中 使用flutter run后报错 Gradle task assembleDebug failed with exit code 1

使用flutter run后报错Gradle task assembleDebug failed with exit code 1
只做了签名 + 应用图标修改、其余在未修改做了签名 + 应用图标修改前都是正常

尝试退回做了签名 + 应用图标的修改后依然还是一样

图片说明

我和你碰到了类似的问题,

这是我这边运行flutter报的错:

Running "flutter pub get" in my_flutter_app...                     943ms
Launching lib\main.dart on M1852 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Could not receive a message from the daemon.

* 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
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         5.6s
Exception: Gradle task assembleDebug failed with exit code 1

代码都没动,早上还可以,下午就一直报这个错。

各种google baidu搜索 都没解决这个问题,什么 flutter doctor,修改配置文件更换为国内的flutter地址

都解决不了。没办法只能自己想办法解决了,

看到这一句话

* 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.

进入到android目录下,用这一条命令.\gradlew assembleDebug --stacktrace,可以看到具体的包错日志

PS E:\workspace\airsmart\my_flutter_app\android> .\gradlew assembleDebug

Welcome to Gradle 6.7!

Here are the highlights of this release:
 - File system watching is ready for production use
 - Declare the version of Java your build requires
 - Java 15 support

For more details see https://docs.gradle.org/6.7/release-notes.html

Starting a Gradle Daemon, 1 busy and 12 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not receive a message from the daemon.

* 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
PS E:\workspace\airsmart\my_flutter_app\android>
PS E:\workspace\airsmart\my_flutter_app\android>
PS E:\workspace\airsmart\my_flutter_app\android>
PS E:\workspace\airsmart\my_flutter_app\android> .\gradlew assembleDebug --stacktrace
Starting a Gradle Daemon, 1 busy and 13 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not receive a message from the daemon.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.launcher.daemon.client.DaemonConnectionException: Could not receive a message from the daemon.
        at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:83)
        at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:167)
        at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:147)
        at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:98)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:57)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:212)
        at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:275)
        at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:247)
        at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
        at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
        at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:92)
        at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:38)
        at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
        at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
        at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:240)
        at org.gradle.launcher.Main.doAction(Main.java:35)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.gradle.internal.remote.internal.MessageIOException: Could not read message from '/127.0.0.1:53153'.
        at org.gradle.internal.remote.internal.inet.SocketConnection.receive(SocketConnection.java:94)
        at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:77)
        ... 32 more
Caused by: com.esotericsoftware.kryo.KryoException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
        at com.esotericsoftware.kryo.io.Input.fill(Input.java:148)
        at com.esotericsoftware.kryo.io.Input.require(Input.java:178)
        at com.esotericsoftware.kryo.io.Input.readVarInt(Input.java:355)
        at com.esotericsoftware.kryo.io.Input.readInt(Input.java:350)
        at org.gradle.internal.serialize.kryo.KryoBackedDecoder.readSmallInt(KryoBackedDecoder.java:127)
        at org.gradle.internal.serialize.DefaultSerializerRegistry$TaggedTypeSerializer.read(DefaultSerializerRegistry.java:142)
        at org.gradle.internal.serialize.Serializers$StatefulSerializerAdapter$1.read(Serializers.java:36)
        at org.gradle.internal.remote.internal.inet.SocketConnection.receive(SocketConnection.java:81)
        ... 33 more
Caused by: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
        at sun.nio.ch.SocketDispatcher.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
        at sun.nio.ch.IOUtil.read(IOUtil.java:192)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
        at org.gradle.internal.remote.internal.inet.SocketConnection$SocketInputStream.read(SocketConnection.java:196)
        at com.esotericsoftware.kryo.io.Input.fill(Input.java:146)
        ... 40 more


* Get more help at https://help.gradle.org

好嘛,终于有日志了,java.io.IOException: 你的主机中的软件中止了一个已建立的连接。

这下就好了,百度下,adb被占用

杀掉adb进程,没用,重启Androidstudio没用。

终于找到了这个,https://blog.csdn.net/heming9174/article/details/108254640

好家伙,竟然是windows的移动热点引起的,关掉移动热点就好了。

淦  就是因为中午打游戏开了热点导致的。

你的gradle有问题吧,或者你运行下 flutter doctor 检测下