今天创建了一个Flutter新项目,编译没有问题,但是安装在手机或者模拟器上时报错:
Exception in thread "main" java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1573)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1468)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1475)
at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1280)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1243)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:732)
at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:841)
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
原因:怀疑是gradle,但是又没有确切的证据,这个通常是因为对应的gradle没有找到,或者gradle文件发生了不可描述的事情遭受损坏
解决方法:修改gradle版本或者删除.gradle(通常位置:C:\Users\xxxx\.gradle)文件
新建项目中使用的是6.7,我修改成
https\://services.gradle.org/distributions/gradle-6.9-all.zip,重新运行即可
|