After I added the next dependecies to my Flutter project:
cloud_firestore: ^0.9.0
firebase_auth: ^0.8.0+1
google_sign_in: ^4.0.0
I tried to run the app by clicking the run button in Android Studio but something weird is happening here:
Case 1: If I open the root Flutter project directory from Android Studio, Let's call it my_flutter_app directory, and click the run button I get the next error:
D8: Cannot fit requested classes in a single dex file (# methods: 68762 > 65536) java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K.
Note: I perfectly understand what that error means and how to solve it, in fact if I add the known line to solve it:
multiDexEnabled true
With its respective dependencies the app is built fine and deployed to the device without getting any errors.
But the weird thing is the next:
Case 2: If I open the android directory of the same Flutter app from Android Studio, I mean my_flutter_app/android directory, and click the run button the app is built fine and deployed to the device without getting any errors. (Yes, without modifying any files, exactly the same scenario for both cases, without the multiDexEnabled true
line)
So, I want to know what is happening here? Why the Android project does not showing me that 64K methods DEX error while the Flutter project does?
I'm trying to keep my develop stuff as clean as possible so I'm hesitating to add that multiDexEnabled true
line if is not necessary, so that's the reason of my question.
EDIT: Here are the contents for each directories:
This is the Flutter root directory view
This is the Android directory view