更新Android Studio 3.1后获取发布签名时出错APK

时间:2018-04-03 03:02:59

标签: android android-studio gradle android-gradle android-studio-3.1

将我现有的项目迁移到Android Studio 3.1后,它没有进行编译。以下是日志详细信息:

  

org.gradle.api.tasks.TaskExecutionException:任务':app:mergeReleaseResources'执行失败。       at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)       在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)       在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)       在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)       在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)       在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)       在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)       在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)       在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)       在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)       在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)       在org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:248)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)       at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)       at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98)       在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)       at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)       at org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)       at org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)       在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)       在java.lang.Thread.run(Thread.java:745)   引起:com.android.build.gradle.tasks.ResourceException:错误:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:检查日志以获取详细信息       在com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:296)       在com.android.build.gradle.internal.tasks.IncrementalTask​​.taskAction(IncrementalTask​​.java:106)       at sun.reflect.GeneratedMethodAccessor352.invoke(未知来源)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       at java.lang.reflect.Method.invoke(Method.java:498)       在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)       在org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:46)       在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)       在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:121)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)       at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)       ......还有32个   引起:错误:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:检查日志以获取详细信息       在com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:332)       在com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:301)       在com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:412)       在com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:285)       ......还有47个       抑制:java.lang.RuntimeException:某些文件处理失败,请参阅日志以获取详细信息           在com.android.builder.internal.aapt.QueuedResourceProcessor.waitForAll(QueuedResourceProcessor.java:121)           在com.android.builder.internal.aapt.QueuedResourceProcessor.end(QueuedResourceProcessor.java:141)           在com.android.builder.internal.aapt.v2.QueueableAapt2.close(QueueableAapt2.java:104)           在com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:293)           ......还有47个   引起:java.util.concurrent.ExecutionException:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:检查日志以获取详细信息       在com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)       在com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)       在com.google.common.util.concurrent.AbstractFuture $ TrustedFuture.get(AbstractFuture.java:79)       在com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:327)       ......还有50个   引起:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:检查日志以获取详细信息       在com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)       在com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)       在com.google.common.util.concurrent.AbstractFuture $ TrustedFuture.get(AbstractFuture.java:79)       在com.android.builder.internal.aapt.v2.QueueableAapt2.lambda $ compile $ 0(QueueableAapt2.java:136)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       ......还有1个   引起: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)

5 个答案:

答案 0 :(得分:13)

检查您的PNG图像,可能是否损坏了真实的png(例如jpeg)

您可以通过在android终端

中键入以下命令来获取虚幻PNG列表
find . -type f -name "*.png" | xargs -L 1 -I{} file  -I {} | grep -v 'image/png; charset=binary$'

答案 1 :(得分:4)

我看到有人将此代码添加到build.gradle 我尝试了它,它解决了我的问题

lintOptions {

    checkReleaseBuilds false

    // Or, if you prefer, you can continue to check for errors in release 
    //builds,
    // but continue the build even when errors are found:

    abortOnError false

}

buildTypes {
    release {
        aaptOptions.cruncherEnabled = false
        aaptOptions.useNewCruncher = false
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
        'proguard-rules.pro'
    }
}

答案 2 :(得分:2)

我只是将minifyEnabled更改为false。

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

答案 3 :(得分:1)

将以下语句添加到gradle.properties文件中:

android.enableAapt2=false

还要确保更新构建工具,gradle插件和gradle版本。

答案 4 :(得分:0)

从gradle.properties文件中删除此行

android.enableAapt2 =假