Android gives error "Cannot fit requested classes in a single dex file"

KevinB picture KevinB · Jul 14, 2018 · Viewed 74.1k times · Source

I don't know why but it's impossible to launch my app on my mobile this morning. I get this error message:

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.

# methods: 68061 > 65536, sources=[Unknown source file], tool

I'm really new to Android and I don't understand the problem and what I need to do? And why I get this problem now and not before?

Answer

Gokul Nath KP picture Gokul Nath KP · Jul 14, 2018

Add dependency in build.gradle file:

implementation 'androidx.multidex:multidex:2.0.1'

In build.gradle's defaultConfig section add:

multiDexEnabled true

More details here: Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536