Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Build errors for cloud_firestore: above version "0.7.4"

I have been trying to resolve a build issue for hours until I realise it is due to Flutter plugin cloud_firestore. Version 0.7.4 builds fine for both Android and iOS but anything above 0.7.4 like 0.8.2+1 will have errors such as:

CloudFirestorePlugin.java:160: error: cannot find symbol query = query.whereArrayContains(fieldName, value); ^ symbol: method whereArrayContains(String,Object) location: variable query of type Query /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:598: error: cannot find symbol builder.setTimestampsInSnapshotsEnabled( ^ symbol: method setTimestampsInSnapshotsEnabled(Boolean) location: variable builder of type Builder /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678: error: cannot find symbol return FieldValue.arrayUnion(toArray(readValue(buffer))); ^ symbol: method arrayUnion(Object[]) location: class FieldValue /dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:680: error: cannot find symbol return FieldValue.arrayRemove(toArray(readValue(buffer))); ^ symbol: method arrayRemove(Object[]) location: class FieldValue Note: /Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 11s Gradle task assembleDebug failed with exit code 1

I would like to use 0.8.2+1 cloud_firestore for both ios and Android because of the support of

await db.settings(timestampsInSnapshotsEnabled: true);

Appreciate some help here. Many Thanks!

like image 916
LiveRock Avatar asked Oct 30 '18 12:10

LiveRock


2 Answers

There is a problem with google-services.json.

In my case, I was in the same situation while coding Firebase for Flutter on Google Codelabs. I put GoogleService-Info.plist in Xcode in the corresponding folder and put google-services.json in the corresponding folder in Adndroid Studio as well. iOS Simulator worked, but in Android Studio the window like the one below is displayed, then pressing the OK button and launching Android Emulator resulted in the corresponding error.

When coding from scratch and inserting the google-services.json file from the Finder instead of Android Studio, no error occurred.

Android Studio Window1 Android Studio Window2

like image 172
RyosukeOK Avatar answered Nov 03 '22 20:11

RyosukeOK


It's not working because it is creating a gradle conflict. Version 0.7.3 of firestore is working because gradle tooling is updated at that version. Please refer changelog and also refer this answer for any other working versions of firebase products.

like image 31
yashthakkar1173 Avatar answered Nov 03 '22 20:11

yashthakkar1173