This is going to be a fairly long question, so I'll include a TL;DR at the end.
For days now, I've been trying to find a way to make my setup work, but to no avail. Now to make it complete and of aid to others, I'll be recording my steps here:
Encounter this error:
Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.android/app/src/main/AndroidManifest.xml. In my case this was com.omnisciamus.fire. Use it to create a new android app in the Firebase project along with a debug key.google-services.json in android/appandroid/build.gradle and android/app/build.gradle. I've changed this to using the latest versions (modifications included below).registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)^ in front of the versions).Changes to the android/build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0' // upgraded from 3.0.1
classpath 'com.google.gms:google-services:3.2.0' // added & upgraded from 3.1.1
}
}
And then we have the android/app/build.gradle:
//bottom of file
apply plugin: 'com.google.gms.google-services'
The dependencies structure of my pubspec looks like this:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
firebase_analytics: 0.3.0
cloud_firestore: 0.3.1
For additional details I've included my flutter doctor -v output:
[√] Flutter (Channel beta, v0.1.5, on Microsoft Windows [Version 10.0.16299.309], locale en-GB)
• Flutter version 0.1.5 at C:\Developer\Flutter\flutter
• Framework revision 3ea4d06340 (5 weeks ago), 2018-02-22 11:12:39 -0800
• Engine revision ead227f118
• Dart version 2.0.0-dev.28.0.flutter-0b4f01f759
[√] Android toolchain - develop for Android devices (Android SDK 27.0.0)
• Android SDK at C:\Android
• Android NDK at C:\Android\ndk-bundle
• Platform android-P, build-tools 27.0.0
• ANDROID_HOME = C:\Android
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[√] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[√] IntelliJ IDEA Ultimate Edition (version 2017.3)
• Flutter plugin version 22.2.2
• Dart plugin version 173.4548.30
[√] VS Code (version 1.21.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Dart Code extension version 2.10.0
[√] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 6.0 (API 23) (emulator)
• No issues found!
As this may become a tutorial I'll include a simple command to obtain the debug key (on Windows):
cd %JAVA_HOME%\bin & keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
Cloud_firestore crashes with a version of 0.3.x, how do you fix this?
As I discussed this with a few co-developers, I discovered that one had found a working setup: changing the version of cloud_firestore to be below 0.3.0, 0.2.9 for instance. According to this recently published issue, the issue is that the 'stable' version of flutter doesn't have certain features that cloud_firestore uses, which causes the errors you see when compiling. I'll update the question in a while to reflect this answer if requested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With