Flutter로 개발한 앱을 Android에서 빌드 할 경우 메쏘드가 64k를 초과했다며 multidex 사용 설정을 하라는 아래와 같은 메시지를 만날때가 있다.
앱 빌드시 다음과 같은 에러메시지가 나타난다
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> 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 44s
[!] App requires Multidex support
Multidex support is required for your android app to build since the number of methods has exceeded 64k.
See https://docs.flutter.dev/deployment/android#enabling-multidex-support for more information.
You may pass the --no-multidex flag to skip Flutter's multidex support to use a manual solution.
Flutter tool can add multidex support. The following file will be added by flutter:
android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java
cannot prompt without a terminal ui
Exception: Gradle task assembleDebug failed with exit code 1
Flutter Multidex 에러 해결 방법
이럴땐 android/app/build.gradle 파일에서 아래와 같이
defaultConfig안에 multiDexEnabled true 를,
dependencies안에 implementation "com.android.support:multidex:2.0.1" 를 추가해주면 된다.
...
android {
...
defaultConfig {
...
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true // 이 줄을 추가!!!
}
...
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:multidex:2.0.1" // 이 줄을 추가!!!
}
이와 같이 Flutter로 안드로이드 빌드할때 만날 수 있는 multidex 에러를 해결하는 방법에 대해서 알아봤습니다.
'개발' 카테고리의 다른 글
flutter upgrade 할때 만난 에러메시지 (0) | 2023.09.02 |
---|---|
Flutter의 ElevatedButton 색상 (0) | 2022.11.28 |
flutter로 만든 macos app에서 network 설정 (0) | 2022.11.12 |
flutter에서 다크모드 테마 적용하기 (0) | 2022.08.29 |
flutter에서 responsive 구현하기 (0) | 2022.08.27 |
댓글