【问题标题】:Flutter problem cloud-firestore dependencyFlutter 问题 cloud-firestore 依赖
【发布时间】:2019-06-26 09:10:18
【问题描述】:

我有一个运行良好的颤振应用程序,但是当我添加 cloud-firestore 依赖项时,它崩溃了:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.1) classpath. You should manually set the same version via DependencyResolution

这里是我的 pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

    #FIRESTORE
    cloud_firestore: ^0.9.0

我该如何解决这个问题?

问候,迭戈

【问题讨论】:

    标签: android flutter google-cloud-firestore


    【解决方案1】:

    似乎我需要更多的配置,而不仅仅是添加 cloud_firestore 依赖项。我已经按照这个教程https://www.gotut.net/flutter-firestore-tutorial-part-1/

    总结一下:

    我不得不将 cloud_firestore: ^0.9.0 更改为 cloud_firestore: ^0.8.2+3。

    Pubspec.yaml:

    environment:
      sdk: ">=2.0.0-dev.68.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
      #FIRESTORE
      cloud_firestore: ^0.8.2+3
    

    .android/build.gradle:

    dependencies {
        ...
        classpath 'com.google.gms:google-services:4.2.0'
    }
    ...
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                      && !details.requested.name.contains('multidex') ) {
                    details.useVersion "26.1.0"
                }
            }
        }
    }
    

    .android/app/build.gradle:

    apply plugin: 'com.google.gms.google-services'
    android {
        defaultConfig {
            ...        
            multiDexEnabled true
        }
    }
    

    【讨论】:

      【解决方案2】:

      发生这种情况是因为依赖项相互冲突。只需将您的 cloud_firestore 降级到旧版本,即将 cloud_firestore: ^0.9.0 替换为 cloud_firestore: ^0.8.2+1 或任何旧版本

      【讨论】:

      • 还是同样的问题……我也试过^0.8.1+1,结果一样……
      • 这应该可以解决问题...将以下配置添加到 android/app/build.gradle configurations.all { resolutionStrategy.force 'com.android.support:support-compat:27.1.1' resolutionStrategy.force 'com.android.support:appcompat-v7:27.1.1' resolutionStrategy.force 'com.android.support:support-v4:27.1.1' }
      • 我必须添加更多配置才能完成这项工作。检查我的答案
      【解决方案3】:

      浪费了太多时间后我刚刚为我工作的设置:

      pubspec.yaml firebase_auth:^0.6.6 google_sign_in: ^3.2.4 firebase_core:^0.2.5+1 cloud_firestore: ^0.8.2+3

      app\build.gradle minSdkVersion 21(原为 16) 并且没有添加到依赖项{ }

      项目 build.gradle 'com.google.gms:google-services:4.0.1'(不是 4.2.0 对上面的 niegus 有效)

      【讨论】:

        猜你喜欢
        • 2018-09-25
        • 2020-03-30
        • 2020-04-03
        • 1970-01-01
        • 2021-06-11
        • 2021-07-31
        • 1970-01-01
        • 2020-04-17
        • 1970-01-01
        相关资源
        最近更新 更多