I have quite big multi module, multi flavor multidex project, but recently I got error when trying to do command line build (assemble{flavor}Release)
Message is:
DexOverflowException: Cannot fit requested classes in the main-dex file
Here is more logs from --debug build:
/Users/bartek/Documents/workspace/android/argus-android/Argus/app/build/intermediates/transforms/dexBuilder/argus/release/1114.jar
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:125)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:110)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 47 more
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:76)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.D8.run(D8.java:67)
15:54:42.645 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:108)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 49 more
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.tools.r8.utils.AbortException
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:77)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:67)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:62)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 52 more
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Suppressed: com.android.tools.r8.errors.DexOverflowException: Cannot fit requested classes in the main-dex file (# methods: 65548 > 65536)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.dex.VirtualFile.throwIfFull(VirtualFile.java:182)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.dex.VirtualFile$DistributorBase.fillForMainDexList(VirtualFile.java:305)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.dex.VirtualFile$FillFilesDistributor.run(VirtualFile.java:353)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.dex.ApplicationWriter.distribute(ApplicationWriter.java:167)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.dex.ApplicationWriter.write(ApplicationWriter.java:187)
15:54:42.646 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.D8.run(D8.java:167)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.D8.lambda$run$0(D8.java:71)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:58)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.r8.D8.run(D8.java:67)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:108)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
15:54:42.647 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:719)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:397)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:221)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.lang.reflect.Method.invoke(Method.java:497)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
15:54:42.648 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
15:54:42.649 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:88)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
15:54:42.650 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:623)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:578)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
15:54:42.651 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.lang.Thread.run(Thread.java:745)
How can I control what goes to main dex file? How to force main dex file to contain less methods?
My setup:
compileSdkVersion 27
buildToolsVersion '27.0.3'
gradlew:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
plugin: classpath 'com.android.tools.build:gradle:3.2.0-alpha04'