[Android] Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

在 “build apk” 或 “make project” 都失敗,Error Message:

Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

解法:

The problem lies in the Multidex. You must add the library in the app gradle :

implementation 'com.android.support:multidex:1.0.3'

After, add in the defaultConfig of the app gradle :

multiDexEnabled true

Your Application must be of the Multidex type.. You must write it in the manifest :

android:name=".MyApplication"

“MyApplication” must be either the Multidex class, or it must extend it.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *