在将我的Android Studio更新到3.0 Canary 4之后的所有新版本后,我收到此错误。(我使用v3.0因为它更快,并且不需要为Kotlin插孔。)
看起来构建流程存在问题,无法为调试版本和发布版本生成或签署我的APK文件。
我还尝试删除我的debug.keystore
,重新启动AndroidStudio和系统(!!!),但它没有解决。
这是一个完整的Gradle日志:
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':chris-app:packageDemoDebug'.
java.io.IOException: Failed to generate v1 signature
* Try: Run with --info or --debug option to get more log output.
* Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':chris-app:packageDemoDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:243)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:236)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:225)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: org.gradle.tooling.BuildException: java.io.IOException: Failed to generate v1 signature
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:240)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:235)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:196)
at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:180)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:466)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:80)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more Caused by: java.lang.RuntimeException: java.io.IOException: Failed to generate v1 signature Caused by: java.io.IOException: Failed to generate v1 signature
at com.android.apkzlib.sign.SigningExtension.onOutputZipReadyForUpdate(SigningExtension.java:297)
at com.android.apkzlib.sign.SigningExtension.access$200(SigningExtension.java:55)
at com.android.apkzlib.sign.SigningExtension$1.lambda$beforeUpdate$2(SigningExtension.java:175)
at com.android.apkzlib.zip.ZFile.notify(ZFile.java:2099)
at com.android.apkzlib.zip.ZFile.update(ZFile.java:871)
at com.android.apkzlib.zip.ZFile.close(ZFile.java:1161)
at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:172)
at com.google.common.io.Closer.close(Closer.java:216)
at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:698)
at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:520)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:185)
at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:202)
at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:224) "
at com.android.apksig.internal.apk.v1.V1SchemeSigner.checkEntryNameValid(V1SchemeSigner.java:406)
at com.android.apksig.internal.apk.v1.V1SchemeSigner.generateManifestFile(V1SchemeSigner.java:373)
at com.android.apksig.internal.apk.v1.V1SchemeSigner.sign(V1SchemeSigner.java:253)
at com.android.apksig.DefaultApkSignerEngine.outputJarEntries(DefaultApkSignerEngine.java:372)
at com.android.apkzlib.sign.SigningExtension.onOutputZipReadyForUpdate(SigningExtension.java:295)
... 13 more
BUILD FAILED in 2m 49s
答案 0 :(得分:7)
使用gradle assemble --stacktrace
命令进行更多调查后,我发现问题与APK压缩过程有关:
错误:org.gradle.tooling.BuildException:无法生成v1 签名错误:java.io.IOException:无法生成v1签名 错误:com.android.apksig.apk.ApkFormatException:不支持的字符 ZIP条目名称中的0x0d" assets / Icon?"
有一个名为" Icon?"在我的项目中,这是一个MacOS文件,指示文件夹的图标,里面包含CR, LF
个字符。
我删除了文件,现在一切正常。
此问题出现在Android Studio Canary 4之后的所有版本中,我在此主题https://issuetracker.google.com/issues/63885809上向Android Studio团队报告此问题
他们提到:
3.0 Canary 4是关于我们添加"不支持的角色"检查,以便它从该版本向前发生的原因。
他们正在调查更多以解决此问题,我希望这个答案可以帮助其他人不浪费一个月不更新他们的Android Studio。 :)
答案 1 :(得分:0)
最初我开始时遇到很多错误"文件名必须以.xml或.png结尾(我也使用Mac OSX)然后我开始删除我发现散落的一堆随机图标文件。结束获取新错误"任务执行失败':app:packageDebug'无法生成v1签名"
最后,有一个很好的建议尝试Build>清理项目然后重新编译。这将强制IDE再次查看文件并再次尝试)。如果删除了图标文件,Android Studio可能需要重新编制项目索引。