Flutter:构建失败,出现异常 [英] Flutter: Build failed with an exception

查看:357
本文介绍了Flutter:构建失败,出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这是我的pubspec.yaml文件

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

推荐答案

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

Well, I was trying to solve it and what I did was:

* 1.-重新安装Flutter

*1.-Reinstall Flutter

2.-重新安装Dart SDK

2.-Reinstall Dart SDK

3.-下载Gradle 5.1.1

3.-Download Gradle 5.1.1

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

4.-Create a new Application with Firebase and include dependencies

5.-再次编译*

所有这些都不起作用.

然后我做了:

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

6.-Copy next lines at the end of gradle.properties

android.useAndroidX=true
android.enableJetifier=true

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

7.-Changes on file app\build.gradle

android {
    compileSdkVersion 28

...

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 28
    multiDexEnabled true
    ...
}

}

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

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.-转到终端并启动命令

9.-Go to terminal and launch command

flutter clean

10.-运行您的应用.

10.-Run your app.

希望会有所帮助

这篇关于Flutter:构建失败,出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆