I have a flutter app that works fine, but when I add the cloud-firestore dependency, it crashes with:
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
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. I've follow this tutorial 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.
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
}
}
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
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
app\\build.gradle minSdkVersion 21 (was 16) and nothing added to dependencies { }
project build.gradle 'com.google.gms:google-services:4.0.1' (Not 4.2.0 which worked for niegus above)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.