调试安卓项目时遇到这个错误:
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.findEND(ZipFile.java:1638)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1646)
at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1484)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1446)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:718)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:252)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:181)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:195)
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)
Error: Gradle task assembleDebug failed with exit code 1
这是Gradle的版本问题,解决方案是打开Gradle官网的下载页面:https://services.gradle.org/distributions/,找到最新的包含all.zip的文件下载路径,例如:gradle-8.7-all.zip
打开Flutter项目的android>gradle>wrapper>gradle-wrapper-properties文件,修改以下代码,例如:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip