简体   繁体   English

Flutter 问题 cloud-firestore 依赖

[英]Flutter problem cloud-firestore dependency

I have a flutter app that works fine, but when I add the cloud-firestore dependency, it crashes with:我有一个运行良好的 flutter 应用程序,但是当我添加 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

Here my pubspec.yaml这是我的 pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

    #FIRESTORE
    cloud_firestore: ^0.9.0

How can I fix this?我怎样才能解决这个问题?

Regards, Diego问候, 迭戈

It seems that I needed more config than just adding the cloud_firestore dependency.似乎我需要更多的配置而不仅仅是添加 cloud_firestore 依赖项。 I've follow this tutorial https://www.gotut.net/flutter-firestore-tutorial-part-1/我已经按照本教程https://www.gotut.net/flutter-firestore-tutorial-part-1/

As a summary:作为总结:

I had to change cloud_firestore: ^0.9.0 to cloud_firestore: ^0.8.2+3.我不得不将 cloud_firestore: ^0.9.0 更改为 cloud_firestore: ^0.8.2+3。

Pubspec.yaml: 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: .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: .android/app/build.gradle:

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

This happened because of dependencies conflicting each other.这是因为依赖关系相互冲突。 Simply downgrade your cloud_firestore to older version ie replace cloud_firestore: ^0.9.0 with cloud_firestore: ^0.8.2+1 or any older version只需将您的 cloud_firestore 降级到旧版本,即用cloud_firestore: ^0.8.2+1或任何旧版本替换cloud_firestore: ^0.9.0

The setting that I have just got to work for me after wasting to much time:在浪费了很多时间之后,我刚刚开始为我工作的设置:

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 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 (was 16) and nothing added to dependencies { } app\\build.gradle minSdkVersion 21(是 16)并且没有添加到依赖项 { }

project build.gradle 'com.google.gms:google-services:4.0.1' (Not 4.2.0 which worked for niegus above)项目 build.gradle 'com.google.gms:google-services:4.0.1' (不是 4.2.0,它适用于上面的 niegus)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM