簡體   English   中英

Firestore依賴性錯誤波動

[英]Firestore dependency error flutter

我有這個運行良好的應用程序。 現在,我需要添加Firestore功能,但無法構建。 控制台錯誤:

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)

app / build.gradle中添加行implementation 'com.google.firebase:firebase-firestore:17.1.0'后出現錯誤

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日志

      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.

我什至嘗試在Android Studio中運行它,但還是一無所獲。 添加其他依賴項( cloud storagecloud messaging ,應用程序將正常構建。 但是在添加firestore行之后,出現錯誤

終於在Stackoverflow的另一篇文章中找到了答案。這些代碼行應添加到build.gradle文件中(模塊:app)。

android {
    defaultConfig {
       multiDexEnabled true
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM