Reputation: 125
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/app
android/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?
Upvotes: 3
Views: 3428
Reputation: 6028
I also had similar issues while using firebase in flutter. I solved it by using this dependencies in my android/build.gradle file and remove any other existing dependencies.
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
and used this version for firestore and google in pubspec.yaml
cloud_firestore: 0.7.3
And if you have version related issues with any other firebase product then refer this link
Upvotes: 0
Reputation: 643
I solved my current Cloud_Firestore problems by:
flutter channel master
. As proposed here Cloud Firestore 0.3.2 - Execution failed for task ...cloud_firestore: "^0.4.0"
even cloud_firestore: "^0.3.2"
.Hope this would help. I spent hours trying to figure it out why I could not compile my flutter app with cloud_firestore. I knew that the issue was around the flutter SDK versions, but I did not wanted to go for alpha. But the solution turned out to be as simple as using the master channel. Although, not sure yet what other issues may arise in the near future. However now, I can happily start testing with cloud firestore. ;)
Upvotes: 2
Reputation: 4054
For the Firebase plugins to work with Swift you need to use newer versions: But I am having android problems as well. I also tried switching flutter channel from beta to dev.
dependencies:
flutter:
sdk: flutter
cloud_firestore: "^0.4.0"
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
dev_dependencies:
flutter_test:
sdk: flutter
image_picker: 0.4.1
#google_sign_in: '>=2.1.0 '
google_sign_in: '3.0.0'
#firebase_analytics: '>=0.2.3'
firebase_auth: '>=0.4.5'
#firebase_auth: '>=0.5.3' #not working on android
#firebase_database: '>=0.3.5' #works on android
firebase_database: '0.4.2' #works on android
#firebase_storage: '>=0.1.4' #not Working on android
#firebase_storage: '0.2.0' #not working on android
Upvotes: 0
Reputation: 125
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.
Upvotes: 3