gpt4 book ai didi

java - Android MainDexClassList 构建错误

转载 作者:行者123 更新时间:2023-12-01 11:34:08 25 4
gpt4 key购买 nike

我有一个 Android 项目通过了 65K 方法限制。我在 build.gradle 中启用了 multidex,然后制作了扩展 Application 的主应用程序文件来扩展 MultiDexApplication。我还适本地覆盖了 AttachBaseContext 方法。现在,在生成签名的 APK 时出现以下错误。

13:24:42.945 [ERROR] [org.gradle.BuildExceptionReporter] 
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter]
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':projectName:createprojectNameReleaseMainDexClassList'.
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/java/bin/java'' finished with non-zero exit value 1
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter]
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
13:24:42.946 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':projectName:createprojectNameReleaseMainDexClassList'.
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
13:24:42.947 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/java/bin/java'' finished with non-zero exit value 1
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:66)
13:24:42.948 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] ... 13 more
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/java/bin/java'' finished with non-zero exit value 1
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:42)
13:24:42.949 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.builder.core.AndroidBuilder.createMainDexList(AndroidBuilder.java:1217)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.builder.core.AndroidBuilder$createMainDexList$3.call(Unknown Source)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.multidex.CreateMainDexList.callDx(CreateMainDexList.groovy:93)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.multidex.CreateMainDexList.this$5$callDx(CreateMainDexList.groovy)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.multidex.CreateMainDexList$this$5$callDx.callCurrent(Unknown Source)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.multidex.CreateMainDexList.output(CreateMainDexList.groovy:64)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] ... 20 more
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.process.internal.ExecException: Process 'command '/usr/java/bin/java'' finished with non-zero exit value 1
13:24:42.950 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
13:24:42.951 [ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:40)
13:24:42.951 [ERROR] [org.gradle.BuildExceptionReporter] ... 27 more
13:24:42.951 [ERROR] [org.gradle.BuildExceptionReporter]

我该怎么做才能克服这个错误?

最佳答案

已修复:需要升级构建工具。当我将构建工具设置为 21 后,它编译得很好!我还在应用程序标签下的 list 中添加了 MultiDex 类条目。 android:name="android.support.multidex.MultiDexApplication"

如果您的 Application 类扩展了 MultiDexApplication,则不确定将其添加到 list 中是否多余。

关于java - Android MainDexClassList 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30174066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com