Reputation: 436
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
Upvotes: 6
Views: 11797
Reputation: 97
If none of the above technique works simply downgrade your gradle build level. This will solve your problem.
dependencies {
`classpath` '`com.android.tools.build:gradle:**3.5.0**`'
}
Upvotes: 0
Reputation: 370
try doing this in the /android/app/build.gradle file:
android {
defaultConfig {
// ...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Upvotes: 0
Reputation: 566
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
Upvotes: 17
Reputation: 51316
In your Project folder > android > app > build.gradle: add the following Line in defaultConfig { .... multiDexEnabled true }
Upvotes: 4