我正在开发一个 Flutter 应用。当我单独使用 cloud_firestore
和 firebase_auth
包时,我的应用程序可以正常工作。但是,当我将它们一起包含在 pubspecs.yaml
文件中时,构建失败并显示以下消息:
Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.7.4/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.5.18/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: /home/saber/Code/mobile_dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.5/android/src/main/java/io/flutter/plugins/firebase/core/FirebaseCorePlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
FAILURE:构建失败并出现异常。
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
以下是我的 pubspec.yaml 文件中的依赖项:
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.5.18
cloud_firestore: ^0.7.4
我检查了软件包的版本,它们似乎都是最新版本。
对于解决此问题的任何帮助将不胜感激!
这可能连接到 this问题,但我不确定。
最佳答案
更新您的 gradle 版本。我遇到了同样的问题,我已经通过以下步骤解决了。
第 1 步: 在 app/build.gradle 中
apply plugin: 'com.google.gms.google-services'
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
****multiDexEnabled true****
}
第 2 步: 在 android/build.gradle 中更改 gradle 版本依赖
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.2.0'
第 3 步: pubspec.ymal 中最新版本的 firebase_auth 和 cloud_firestore
cloud_firestore: ^0.12.5+1
firebase_auth: ^0.11.1+6
google_sign_in: ^4.0.2
关于firebase - Flutter 中的 cloud_firestore 和 firebase_auth 兼容性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51843822/