Exception: Gradle task assembleDebug failed with exit code 1

Exception: Gradle task assembleDebug failed with exit code 1

问题描述:

Launching lib\main.dart on Phone one in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.util.zip.ZipException: zip END header not found
	at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1581)
	at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1476)
	at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1483)
	at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1288)
	at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1251)
	at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:732)
	at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:849)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:247)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:177)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:191)
	at org.gradle.wrapper.Install.unzip(Install.java:214)
	at org.gradle.wrapper.Install.access$600(Install.java:27)
	at org.gradle.wrapper.Install$1.call(Install.java:74)
	at org.gradle.wrapper.Install$1.call(Install.java:48)
	at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
	at org.gradle.wrapper.Install.createDist(Install.java:48)
	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1

Exception: Gradle task assembleDebug failed with exit code 1

解决方案:

出现这个问题,可能是依赖的插件无法下载

找到项目的android->build.gradle,

Exception: Gradle task assembleDebug failed with exit code 1_第1张图片

google()
mavenCentral()

替换为

        maven{url 'https://maven.aliyun.com/repository/google' }
        maven{url 'https://maven.aliyun.com/repository/google-plugin' }
        maven{url 'https://maven.aliyun.com/repository/public' }
        maven{url 'https://maven.aliyun.com/repository/jcenter' }

Exception: Gradle task assembleDebug failed with exit code 1_第2张图片

打开flutter SDK中packages-> flutter_tools ->grale-> flutter.gradle

        maven{url 'https://maven.aliyun.com/repository/google' }
        maven{url 'https://maven.aliyun.com/repository/google-plugin' }
        maven{url 'https://maven.aliyun.com/repository/public' }
        maven{url 'https://maven.aliyun.com/repository/jcenter' }

添加到google()的前面
Exception: Gradle task assembleDebug failed with exit code 1_第3张图片

如果上面的方法还,没有解决

找到自己问题的gradle-6.7-all文件,将其删除,重新下载一次。
Exception: Gradle task assembleDebug failed with exit code 1_第4张图片
如果还不行,那可能是 gradle包版本, 与你的的 Androidstudio 的版本不匹配导致的.找到gradle-wrapper.properties文件
Exception: Gradle task assembleDebug failed with exit code 1_第5张图片
更改gradle包的版本,可以尝试降版,最新的不一定最好用。
Exception: Gradle task assembleDebug failed with exit code 1_第6张图片
最后成功运行。
Exception: Gradle task assembleDebug failed with exit code 1_第7张图片

你可能感兴趣的:(浅识Flutter笔记,gradle,java,flutter)