2015-05-11 83 views
0

我有一個通過65K方法限制的android項目。我在build.gradle中啓用了multidex,然後使我的主應用程序文件擴展了Application以擴展MultiDexApplication。我也適當地重寫了attachBaseContext方法。在生成簽名的APK時,我現在得到以下錯誤。MainDexClassList構建錯誤Android

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] 

我能做些什麼來克服這個錯誤?

+0

Post'build.gradle.' –

回答

1

修正:需要升級構建工具。在我將build工具設置爲21之後,它編譯好了!我還添加了MultiDex類入口到應用程序標籤下的清單中。 android:name="android.support.multidex.MultiDexApplication"

如果您的Application類擴展了MultiDexApplication,則不確定是否將它添加到清單是多餘的。