我尝试生成签名的apk时遇到问题。我的应用程序运行正常,即使我构建的apk android studio也没有给我任何错误。 但是,当我尝试生成签名的apk时,出现“ AApt2错误”。
奇怪的是,我已经在Google上搜索过,我尝试设置ut.studio的“ android.enableAAPT2 = false”,这使我感到厌烦。
感谢您的帮助,对不起我的英语! 但是我只有十七岁,我是意大利人:S
这些是我得到的错误:
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:mergeReleaseResources'.
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:mergeReleaseResources'.
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeReleaseResources'.
... 62 more
Caused by: com.android.build.gradle.tasks.ResourceException: Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:296)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
... 105 more
Caused by: Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:332)
at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:301)
at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:412)
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:285)
... 117 more
Suppressed: java.lang.RuntimeException: Some file processing failed, see logs for details
at com.android.builder.internal.aapt.QueuedResourceProcessor.waitForAll(QueuedResourceProcessor.java:121)
at com.android.builder.internal.aapt.QueuedResourceProcessor.end(QueuedResourceProcessor.java:141)
at com.android.builder.internal.aapt.v2.QueueableAapt2.close(QueueableAapt2.java:104)
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:293)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:327)
... 120 more
Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$compile$0(QueueableAapt2.java:136)
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:443)
at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:395)
at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:312)
at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
答案 0 :(得分:0)
查看日志:
起因:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2 错误:检查日志以获取详细信息 在com.android.builder.png.AaptProcess $ NotifierProcessOutput.handleOutput(AaptProcess.java:443) 在com.android.builder.png.AaptProcess $ NotifierProcessOutput.err(AaptProcess.java:395) 在com.android.builder.png.AaptProcess $ ProcessOutputFacade.err(AaptProcess.java:312) 在com.android.utils.GrabProcessOutput $ 1.run(GrabProcessOutput.java:104))
由于某些PNG文件已损坏或未解析而导致构建失败的原因之一。有时图像具有扩展名,但不是真正的PNG。
您可以使用以下命令检查项目中的图像是否为真实的PNG:
find . -type f -name "*.png" | xargs -L 1 -I{} file -I {} | grep -v 'image/png; charset=binary$'
获取列表后,使用this网站将其转换为PNG。然后再次检查构建。