안드로이드 스튜디오에서 다음과 같은 오류를 얻었다.
기존에 Java로 안드로이드 개발할 때를 생각하면 Multidex와 관련된 이슈로 보여 찾아보았다.
[+32411 ms] D8: Cannot fit requested classes in a single dex file (# methods: 81089 > 65536)
[ +1 ms] com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
[ ] The number of method references in a .dex file cannot exceed 64K.
[ ] Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
[ ] at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
[ ] at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
[ ] at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
[ ] at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:444)
[ ] at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
[ ] at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39)
[ ] at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
[ ] at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
[ ] at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
[ ] at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
[ ] at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
[ ] at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
[ ] at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:55)
[ ] at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:105)
[ ] at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:99)
[ ] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[ ] at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
[ ] at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
[ ] at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
[ ] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[ ] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[ ] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
[ ] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
[ ] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[ ] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[ ] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
[ ] at java.lang.Thread.run(Thread.java:748)
[ ] Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
[ ] at com.android.tools.r8.utils.t.a(:55)
[ ] at com.android.tools.r8.D8.run(:11)
[ ] at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
[ ] ... 30 more
[ ] Caused by: com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# methods: 81089 > 65536)
[ ] at com.android.tools.r8.utils.Reporter.a(:21)
[ ] at com.android.tools.r8.utils.Reporter.a(:7)
[ ] at com.android.tools.r8.dex.VirtualFile.a(:33)
[ ] at com.android.tools.r8.dex.VirtualFile$h.a(:5)
[ ] at com.android.tools.r8.dex.ApplicationWriter.a(:13)
[ ] at com.android.tools.r8.dex.ApplicationWriter.write(:35)
[ ] at com.android.tools.r8.D8.d(:44)
[ ] at com.android.tools.r8.D8.b(:1)
[ ] at com.android.tools.r8.utils.t.a(:23)
[ ] ... 32 more
[ +479 ms] FAILURE: Build failed with an exception.
[ ] * What went wrong:
[ ] Execution failed for task ':app:mergeDexDebug'.
[ ] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[ ] > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
[ ] The number of method references in a .dex file cannot exceed 64K.
[ ] Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
[ ] * Try:
[ ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[ ] * Get more help at https://help.gradle.org
[ ] BUILD FAILED in 1m 22s
android/app/build.gradle에 multiDexEnabled true 와 implementation 'com.android.support:multidex:1.0.3'를 추가해주니 해결되었다.
android {
compileSdkVersion 28
...
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
...
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
...
이 글이 도움이 되었다면 좋아요(하트)를 눌러주세요~!