1

I have this app that is working perfectly. Now i need to add firestore functionality and it fails to build. Console error:

Launching lib\main.dart on Phone in debug mode...
Configuration 'compile' in project ':app' is deprecated. Use 
'implementation' instead.
registerResGeneratingTask is deprecated, use 
registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use 
registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use 
registerGeneratedFolders(FileCollection)

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

BUILD FAILED in 2m 3s
Gradle build failed: 1
Exited (sigterm)

The error comes after adding the line implementation 'com.google.firebase:firebase-firestore:17.1.0' in the app/build.gradle

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.1'
compile 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-firestore:17.1.0'  //if I comment out this line the app compiles and builds normally. 
//Also I can use FirebaseAuth in the app so I don't think I have wrongly configured Firebase
}

Gradlew logs

      Task :app:compileDebugJavaWithJavac
Putting task artifact state for task ':app:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory 'C:\Users\rober\OneDrive\Documents\VS\appname\android\app\src\debug\java', not found
Skipping task ':app:compileDebugJavaWithJavac' as it is up-to-date (took 0.117 secs).

:app:compileDebugJavaWithJavac (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.136 secs.
:app:transformClassesWithDexBuilderForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformClassesWithDexBuilderForDebug
Putting task artifact state for task ':app:transformClassesWithDexBuilderForDebug' into context took 0.0 secs.
Skipping task ':app:transformClassesWithDexBuilderForDebug' as it is up-to-date (took 0.162 secs).

:app:transformClassesWithDexBuilderForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.162 secs.
:app:transformDexArchiveWithExternalLibsDexMergerForDebug (Thread[Daemon worker Thread 7,5,main]) started.

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug
Putting task artifact state for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' into context took 0.0 secs.
Executing task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' (up-to-date check took 0.077 secs) due to:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

:app:transformDexArchiveWithExternalLibsDexMergerForDebug (Thread[Daemon worker Thread 7,5,main]) completed. Took 1.029 secs.

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 --debug option to get more log output.

I have even tried running it in Android studio and still nothing. Adding other dependencies like cloud storage and cloud messaging and the app builds normally. But after adding the firestore line, the error appears

6
  • I have added the flutter run -v logs Commented Aug 25, 2018 at 12:57
  • How exactly do I do that, the --info part Commented Aug 25, 2018 at 13:04
  • You can just run the part that causes the failure isolated: projectDir/android/gradlew transformDexArchiveWithExternalLibsDexMergerForDebug --info. The appended --info, which flutter run does not use, will show you the actual DexMerger error. Commented Aug 25, 2018 at 13:25
  • when i run this it opens cmd and starts running on completion. cmd just exits without giving time to read the result. So i run the command in the cmd directly and the result i have posted but am not sure it is the error exactly Commented Aug 25, 2018 at 13:52
  • no. Found what i was doing wrong. Check log updates Commented Aug 25, 2018 at 14:02

1 Answer 1

2

Finally found an answer in another post on Stackoverflow still These lines of code should be added in build.gradle file (Module: app).

android {
    defaultConfig {
       multiDexEnabled true
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

That is what I suspected firstly, but the updates of your posts did not help me in that regard.
it would also work without adding multiDexEnabled = true if you change the firestore version to 16.0.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.