I am trying to use FirebaseAuth in a flutter application. I can use Firestore service but when i include firebase_auth depedency in pubspec.yaml file i got the following exception.
FAILURE: Build failed with an exception. * What went wrong:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex * Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org
here is my pubspec.yaml file
dependencies: flutter: sdk: flutter intl: ^0.15.6 #firebase_core: ^0.2.2 google_sign_in: git: url: http://github.com/jahirhstu/flutter_plugins.git path: packages/google_sign_in #firebase_analytics: # git: # url: http://github.com/jahirhstu/flutter_plugins.git # path: packages/firebase_analytics firebase_auth: git: url: http://github.com/jahirhstu/flutter_plugins.git path: packages/firebase_auth cloud_firestore: git: url: http://github.com/jahirhstu/flutter_plugins.git path: packages/cloud_firestore cupertino_icons: ^0.1.0 shrine_images: 1.0.0 dev_dependencies: flutter_test: sdk: flutter
Method 1: Run Command Flutter Clean Open your flutter project folder in Command Prompt or Terminal. Then type flutter clean command and press enter. After executing flutter clean command we would see that it will delete the dart-tools folder, android folder and iOS folder in our application with debug file.
Well, I was trying to solve it and what I did was:
*1.-Reinstall Flutter
2.-Reinstall Dart SDK
3.-Download Gradle 5.1.1
4.-Create a new Application with Firebase and include dependencies
5.-Compile again*
And all of these didnt work.
Then I did:
6.-Copy next lines at the end of gradle.properties
android.useAndroidX=true
android.enableJetifier=true
7.-Changes on file app\build.gradle
android {
compileSdkVersion 28
...
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
...
}
}
8.-Optionally you can add code inside subproject{} in file android\build.gradle
subprojects {
...
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
}
}
9.-Go to terminal and launch command
flutter clean
10.-Run your app.
Hope will be helpful
In your Project folder > android > app > build.gradle: add the following Line in defaultConfig { .... multiDexEnabled true }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With