Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot fit requested classes in a single dex file (# methods: 67593 > 65536)

How to solve this error I'm getting in Android Studio:

Error: Cannot fit requested classes in a single dex file (# methods: 67593 > 65536)

cant build my project now

like image 311
sah Rishabh Avatar asked Mar 05 '23 06:03

sah Rishabh


2 Answers

Do this 4 step

1: Add this library in dependencies of the app build.gradle :

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

2: Add in the defaultConfig of the app build.gradle :

defaultConfig {
    //other configs
    multiDexEnabled true //add this line
}

3: Create new Java class like this :

public class ApplicationClass extends MultiDexApplication {
    @Override
    public void onCreate() {
           super.onCreate();
    }
}

4: Add this to your manifest (in application tag):

<application
    android:name=".ApplicationClass"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name">
like image 145
Radesh Avatar answered Mar 10 '23 10:03

Radesh


Same situation happened in my Visual Studio 2019 Xamarin project, and the way to solve this problem is just like what mentioned in the link: Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536

multiDexEnabled true

By checking the Enable multiDex checkbox in the option page of the ***.Droid project solves the problem.

like image 34
Edward Avatar answered Mar 10 '23 11:03

Edward