Flutter:构建失败,出现异常

jah*_*stu 4 firebase firebase-authentication flutter

我正在尝试在Flutter应用程序中使用FirebaseAuth。我可以使用Firestore服务,但是当我在pubspec.yaml文件中包含firebase_auth权限时,出现以下异常。

失败:构建失败,发生异常。

*出了什么问题:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。
> java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex
* Try:Run---stacktrace选项以获取堆栈跟踪。使用--info或--debug选项运行以获取
更多日志输出。

*在https://help.gradle.org上获得更多帮助

这是我的pubspec.yaml文件

依赖项:
  扑:
    SDK:颤振
  国际:^ 0.15.6
  #firebase_core:^ 0.2.2
  google_sign_in:
    git:
      网址:http://github.com/jahirhstu/flutter_plugins.git
      路径:packages / google_sign_in
  #firebase_analytics: 
  #git:
  #网址:http://github.com/jahirhstu/flutter_plugins.git
  #路径:packages / firebase_analytics
  firebase_auth:
    git:
      网址:http://github.com/jahirhstu/flutter_plugins.git
      路径:packages / firebase_auth
  cloud_firestore:
    git:
      网址:http://github.com/jahirhstu/flutter_plugins.git
      路径:packages / cloud_firestore
  cupertino_icons:^ 0.1.0
  shrine_images:1.0.0

dev_dependencies:
  flutter_test:
    SDK:颤振

Yur*_*eda 16

好吧,我正在尝试解决它,而我所做的是:

* 1。-重新安装Flutter

2.-重新安装Dart SDK

3.-下载Gradle 5.1.1

4.-使用Firebase创建一个新应用程序并包含依赖项

5.-再次编译*

和所有这些没有工作。

然后我做了:

6.-在gradle.properties的末尾复制下一行

android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)

7.-更改文件app \ build.gradle

android {
    compileSdkVersion 28

...

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 28
    multiDexEnabled true
    ...
}
Run Code Online (Sandbox Code Playgroud)

}

8 .-(可选)您可以在子项目{}中添加代码到android \ build.gradle文件中

subprojects {
    ...
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

9.-转到终端并启动命令

flutter clean
Run Code Online (Sandbox Code Playgroud)

10.-运行您的应用程序。

希望会有所帮助


anm*_*ail 4

在您的项目文件夹 > android > app > build.gradle 中:在 defaultConfig { .... multiDexEnabled true } 中添加以下行

在此输入图像描述