Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to add fused location services but it shows me some error. Help me.

apply plugin: 'com.android.application'  android {     compileSdkVersion 26     buildToolsVersion "27.0.1"     defaultConfig {         applicationId "com.example.adil.bloodbankapplication"         minSdkVersion 15         targetSdkVersion 26         versionCode 1         versionName "1.0"         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"     }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile fileTree(include: ['*.jar'], dir: 'libs')     compile 'com.android.support:appcompat-v7:26.1.0'     compile 'com.android.support.constraint:constraint-layout:1.0.2'     compile 'com.google.firebase:firebase-auth:11.8.0'     compile 'com.google.firebase:firebase-database:11.8.0'     compile 'com.android.support:support-v4:26.1.0'     compile 'junit:junit:4.12'     compile 'com.android.support:design:26.1.0'     compile 'com.github.joielechong:countrycodepicker:2.1.5'     compile 'com.jaredrummler:material-spinner:1.2.4'     compile 'hanks.xyz:htextview-library:0.1.5'     compile 'com.firebaseui:firebase-ui-database:1.2.0'     compile 'com.google.android.gms:play-services:11.8.0' }   apply plugin: 'com.google.gms.google-services' 
like image 859
Muhammad Adil Sattar Avatar asked Jan 14 '18 12:01

Muhammad Adil Sattar


People also ask

How to solve Cannot fit requested classes in a single dex file?

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.

What is multidexEnabled in Android?

Android applications by default have SingleDex support which limits your application to have only 65536 methods(references). So multidexEnabled = true simply means that now you can write more than 65536 methods(references) in your application.


1 Answers

None of the answers they gave you was exhaustive. 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.

like image 110
AlexPad Avatar answered Sep 18 '22 20:09

AlexPad