Flutter:构建失败,出现异常

时间:2018-09-19 15:39:42

标签: firebase firebase-authentication flutter

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

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文件


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

4 个答案:

答案 0 :(得分:10)

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

* 1.-重新安装Flutter

2.-重新安装Dart SDK

3.-下载Gradle 5.1.1

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

5.-再次编译*

所有这些都不起作用。

然后我做了:

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

android.useAndroidX=true
android.enableJetifier=true

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

android {
    compileSdkVersion 28

...

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

}

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

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

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

flutter clean

10。-运行您的应用。

希望会有所帮助

答案 1 :(得分:4)

在您的Project文件夹> android> app> build.gradle中: 在defaultConfig {.... multiDexEnabled true}

中添加以下行

enter image description here

答案 2 :(得分:0)

尝试在/android/app/build.gradle文件中执行此操作:

everyOtherEven :: [Int] -> Bool
everyOtherEven = all myEven . zip [0..]
  where
    myEven (idx, v) = odd idx || even v

答案 3 :(得分:0)

如果上述技术都不起作用,只需降级您的 gradle 构建级别。这将解决您的问题。

dependencies {
    `classpath` '`com.android.tools.build:gradle:**3.5.0**`'
}