Hello Guys, How are you all? Hope You all Are Fine. Today Cannot fit requested classes in a single dex file. Try supplying a main-dex list in Java. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How This Error Occurs ?
I am facing following error while run my app.
Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
# methods: 68061 > 65536 Message{kind=ERROR, text=Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
How To Solve Cannot fit requested classes in a single dex file. Try supplying a main-dex list Error ?
- How To Solve Cannot fit requested classes in a single dex file. Try supplying a main-dex list Error ?
To Solve Cannot fit requested classes in a single dex file. Try supplying a main-dex list Error You just need to Add dependency androidx.multidex:multidex:2.0.1 in
build.gradle
file. Just like this: implementation ‘androidx.multidex:multidex:2.0.1’ And also You need to set multiDexEnabled to true Inbuild.gradle
‘sdefaultConfig
section add: multiDexEnabled true Now Your error must be solved. - Cannot fit requested classes in a single dex file. Try supplying a main-dex list
To Solve Cannot fit requested classes in a single dex file. Try supplying a main-dex list Error You just need to Add dependency androidx.multidex:multidex:2.0.1 in
build.gradle
file. Just like this: implementation ‘androidx.multidex:multidex:2.0.1’ And also You need to set multiDexEnabled to true Inbuild.gradle
‘sdefaultConfig
section add: multiDexEnabled true Now Your error must be solved.
Solution 1: Add dependency in build.gradle
You just need to Add dependency androidx.multidex:multidex:2.0.1 in build.gradle
file. Just like this.
implementation 'androidx.multidex:multidex:2.0.1'
And also You need to set multiDexEnabled to true In build.gradle
‘s defaultConfig
section add.
android {
defaultConfig {
...
minSdkVersion 21 <----- *OPTIONAL
targetSdkVersion 26
multiDexEnabled true <------ *here
}
...
}
Now Your error must be solved.
Solution 2: Androidx Users
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true //ADD THIS LINE
}
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read