MAKE IT SIMPLE

[Flutter] D8: Cannot fit requested classes in a single dex file 본문

Flutter/에러 노트

[Flutter] D8: Cannot fit requested classes in a single dex file

punchlips 2021. 8. 4. 22:53

D8: Cannot fit requested classes in a single dex file

애뮬레이터 실행시키는데 또 생천 첨보는 에러가 났다...

구글링해보니 안드로이드 SDK 버전에 따라 멀티덱스(multidex)를 지원하는지 여부가 달라서 그렇다고 한다.

아무튼 SDK 버전 문제이니 해결법은 2가지가 있다.

 


 

1. SDK 버전 올리기 

.android/app/build.gradle 를 열어서 minSdkVersion 16 → minSdkVersion 21로 변경

 

 

2. multidex 활성화

defaultConfig 블록에서 multidex를 활성화(true) 해주고 dependency를 추가해주면 된다

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility 11
        targetCompatibility 11
    }

    defaultConfig {
        applicationId "com.test.example"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        multiDexEnabled true //멀티덱스 활성화
    }

   .
   .
   .
}

...

dependencies {
    .
    .
    .
    //dependency 추가
    implementation "androidx.multidex:multidex:2.0.1"
}

 

이제 실행이 잘된당ㅎㅎ 해결!!

Comments