When I try to setData to a nested collection in cloud firestore , this error comes and forces my app to shut down but it happens only one particular collection and none other collection.
D/AndroidRuntime( 9744): Shutting down VM
E/AndroidRuntime( 9744): FATAL EXCEPTION: main
E/AndroidRuntime( 9744): Process: com.example.chatbot, PID: 9744
E/AndroidRuntime( 9744): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime( 9744): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451)
E/AndroidRuntime( 9744): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433)
E/AndroidRuntime( 9744): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025)
E/AndroidRuntime( 9744): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6)
E/AndroidRuntime( 9744): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42)
E/AndroidRuntime( 9744): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
E/AndroidRuntime( 9744): at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime( 9744): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime( 9744): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 9744): at android.app.ActivityThread.main(ActivityThread.java:7682)
E/AndroidRuntime( 9744): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9744): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E/AndroidRuntime( 9744): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I/Process ( 9744): Sending signal. PID: 9744 SIG: 9
Lost connection to device.
Hi @Aashishm178 please could you show some code usage.
This is happening when i am clicking the button
Here is the function of the button click
Its purpose is to setData on the specified document in cloud firestore but it is crashing my app but the data is been set to firestore , I checked it through my firebase console , the changes which were intended were happening but my app keeps on crashing again again.
It is inside a stream builder which has a listview.builder child
try {
await _firestore
.collection(
'users')
.document(snapshot
.data
.documents[index]
[
'UserId'])
.collection(
'FriendRequest')
.document()
.setData({
'UserId': widget
.firebaseUser
.uid,
'UserEmail': widget
.firebaseUser
.email,
'time': DateTime
.now()
.toIso8601String(),
});
Navigator.of(
context)
.pop();
scaffoldKey
.currentState
.hideCurrentSnackBar();
SnackBar snack = SnackBar(
action: SnackBarAction(
textColor:
Colors
.purpleAccent,
label:
'OK',
onPressed:
() {}),
elevation:
6.0,
behavior:
SnackBarBehavior
.floating,
duration:
Duration(
seconds:
4),
content: Text(
'REQUEST SENT SUCCESSFULLY'));
scaffoldKey
.currentState
.showSnackBar(
snack);
searchController
.clear();
} catch (error) {
print(error);
}
When I try to send a message the app crashes. It's strange cause it works nice the 1st time the app is launched, then I reopen the app and then it crashes, and then I close again an reopen again and it works again, and that goes on and on:
D/AndroidRuntime(25841): Shutting down VM
E/AndroidRuntime(25841): FATAL EXCEPTION: main
E/AndroidRuntime(25841): Process: com.example.social_doctor_app, PID: 25841
E/AndroidRuntime(25841): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime(25841): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451)
E/AndroidRuntime(25841): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433)
E/AndroidRuntime(25841): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025)
E/AndroidRuntime(25841): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6)
E/AndroidRuntime(25841): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42)
E/AndroidRuntime(25841): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
E/AndroidRuntime(25841): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(25841): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(25841): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(25841): at android.app.ActivityThread.main(ActivityThread.java:6865)
E/AndroidRuntime(25841): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(25841): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
E/AndroidRuntime(25841): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
my code:
InkResponse(
onTap: () {
if (_tecMessage.text.isNotEmpty) {
_blocChat.add(
Event(
ChatEventType.sendMessageButtonPressed,
data: _tecMessage.text.trim(),
),
);
_tecMessage.clear();
}
},
child: Container(
margin: EdgeInsets.all(5.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).primaryColor,
),
padding: EdgeInsets.all(12.0),
child: SvgPicture.asset(
'lib/main/images/ic_chat_send_white.svg',
),
),
),
pressing the button executes this code on the bloc:
case ChatEventType.sendMessageButtonPressed:
try {
await _firestore.collection(_tableName).add(<String, dynamic>{
'message': event.data,
'date': FieldValue.serverTimestamp(),
'fk_from': _userType == 1 ? _patientId : _doctorId,
});
} catch (e, s) {
print('${this.runtimeType} -> $e | $s');
}
yield event;
break;
Flutter doctor -v:
[β] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57, locale es-ES)
β’ Flutter version 1.12.13+hotfix.8 at /Users/jose/developement/flutter
β’ Framework revision 0b8abb4724 (2 months ago), 2020-02-11 11:44:36 -0800
β’ Engine revision e1e6ced81d
β’ Dart version 2.7.0
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
β’ Android SDK at /Users/jose/Library/Android/sdk
β’ Android NDK location not configured (optional; useful for native profiling support)
β’ Platform android-29, build-tools 29.0.2
β’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
β’ All Android licenses accepted.
[β] Xcode - develop for iOS and macOS (Xcode 11.4)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 11.4, Build version 11E146
β’ CocoaPods version 1.9.1
[β] Android Studio (version 3.5)
β’ Android Studio at /Applications/Android Studio.app/Contents
β’ Flutter plugin version 44.0.1
β’ Dart plugin version 191.8593
β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[β] VS Code (version 1.44.2)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.9.1
[β] Connected device (1 available)
β’ 5024D EEA β’ V7LB18BBMMC01BI β’ android-arm64 β’ Android 9 (API 28)
β’ No issues found!
I have tried with flutter run and with flutter run --release
cloud_firestore: ^0.13.5
When I try to send a message the app crashes. It's strange cause it works nice the 1st time the app is launched, then I reopen the app and then it crashes, and then I close again an reopen again and it works again, and that goes on and on:
D/AndroidRuntime(25841): Shutting down VM E/AndroidRuntime(25841): FATAL EXCEPTION: main E/AndroidRuntime(25841): Process: com.example.social_doctor_app, PID: 25841 E/AndroidRuntime(25841): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference E/AndroidRuntime(25841): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451) E/AndroidRuntime(25841): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433) E/AndroidRuntime(25841): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025) E/AndroidRuntime(25841): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6) E/AndroidRuntime(25841): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42) E/AndroidRuntime(25841): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6) E/AndroidRuntime(25841): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime(25841): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(25841): at android.os.Looper.loop(Looper.java:193) E/AndroidRuntime(25841): at android.app.ActivityThread.main(ActivityThread.java:6865) E/AndroidRuntime(25841): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(25841): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504) E/AndroidRuntime(25841): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)my code:
InkResponse( onTap: () { if (_tecMessage.text.isNotEmpty) { _blocChat.add( Event( ChatEventType.sendMessageButtonPressed, data: _tecMessage.text.trim(), ), ); _tecMessage.clear(); } }, child: Container( margin: EdgeInsets.all(5.0), decoration: BoxDecoration( shape: BoxShape.circle, color: Theme.of(context).primaryColor, ), padding: EdgeInsets.all(12.0), child: SvgPicture.asset( 'lib/main/images/ic_chat_send_white.svg', ), ), ),pressing the button executes this code on the bloc:
case ChatEventType.sendMessageButtonPressed: try { await _firestore.collection(_tableName).add(<String, dynamic>{ 'message': event.data, 'date': FieldValue.serverTimestamp(), 'fk_from': _userType == 1 ? _patientId : _doctorId, }); } catch (e, s) { print('${this.runtimeType} -> $e | $s'); } yield event; break;Flutter doctor -v:
[β] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57, locale es-ES) β’ Flutter version 1.12.13+hotfix.8 at /Users/jose/developement/flutter β’ Framework revision 0b8abb4724 (2 months ago), 2020-02-11 11:44:36 -0800 β’ Engine revision e1e6ced81d β’ Dart version 2.7.0 [β] Android toolchain - develop for Android devices (Android SDK version 29.0.2) β’ Android SDK at /Users/jose/Library/Android/sdk β’ Android NDK location not configured (optional; useful for native profiling support) β’ Platform android-29, build-tools 29.0.2 β’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) β’ All Android licenses accepted. [β] Xcode - develop for iOS and macOS (Xcode 11.4) β’ Xcode at /Applications/Xcode.app/Contents/Developer β’ Xcode 11.4, Build version 11E146 β’ CocoaPods version 1.9.1 [β] Android Studio (version 3.5) β’ Android Studio at /Applications/Android Studio.app/Contents β’ Flutter plugin version 44.0.1 β’ Dart plugin version 191.8593 β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) [β] VS Code (version 1.44.2) β’ VS Code at /Applications/Visual Studio Code.app/Contents β’ Flutter extension version 3.9.1 [β] Connected device (1 available) β’ 5024D EEA β’ V7LB18BBMMC01BI β’ android-arm64 β’ Android 9 (API 28) β’ No issues found!I have tried with flutter run and with flutter run --release
cloud_firestore: ^0.13.5
I have the same exact issue with cloud_firestore plugin
Sometimes it works and sometimes it crashes the app
UPDATE
I can confirm that this is not happening with version 0.13.1
This error occurs also on cloud_firestore 0.13.5. The stack trace is a bit different, but the reason seems to be similar. I don't have reproducible steps unfrotunately.
Using with current beta Flutter v1.17.0-33.2.pre
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void e.b.b.a.j.a(java.lang.String, java.lang.Object)' on a null object reference
at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.a(CloudFirestorePlugin.java:106)
at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.a(CloudFirestorePlugin.java:2)
at com.google.firebase.firestore.DocumentReference.a(DocumentReference.java:87)
at com.google.firebase.firestore.DocumentReference$$Lambda$3.a(DocumentReference.java:6)
at com.google.firebase.firestore.core.AsyncEventListener.a(AsyncEventListener.java:6)
at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(AsyncEventListener.java:6)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6854)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
I believe that this issue shouldn't have blocked: customer-response label anymore
I face this error in the following scenario:
I'm working with a StreamBuilder and cloud_firestore: ^0.13.5
Shutting down VM
E/AndroidRuntime(32722): FATAL EXCEPTION: main
E/AndroidRuntime(32722): Process: br.com.test, PID: 32722
E/AndroidRuntime(32722): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime(32722): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451)
E/AndroidRuntime(32722): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433)
E/AndroidRuntime(32722): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025)
E/AndroidRuntime(32722): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6)
E/AndroidRuntime(32722): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42)
E/AndroidRuntime(32722): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
E/AndroidRuntime(32722): at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime(32722): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(32722): at android.os.Looper.loop(Looper.java:235)
E/AndroidRuntime(32722): at android.app.ActivityThread.main(ActivityThread.java:7441)
E/AndroidRuntime(32722): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32722): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(32722): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
flutter doctor -v
[β] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [versΓΒ£o 10.0.18363.592], locale pt-BR)
β’ Flutter version 1.12.13+hotfix.9 at C:\src\flutter
β’ Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700
β’ Engine revision af51afceb8
β’ Dart version 2.7.2
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
β’ Android SDK at C:\Users\hudso\AppData\Local\Android\sdk
β’ Android NDK location not configured (optional; useful for native profiling support)
β’ Platform android-29, build-tools 29.0.3
β’ Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
β’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
β’ All Android licenses accepted.
[β] Android Studio (version 3.6)
β’ Android Studio at C:\Program Files\Android\Android Studio
β’ Flutter plugin version 45.1.1
β’ Dart plugin version 192.7761
β’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[β] Connected device (2 available)
β’ XT1033 β’ [I REMOVED IT] β’ android-arm β’ Android 5.1 (API 22)
β’ ASUS Z01RD β’ [I REMOVED IT] β’ android-arm64 β’ Android 10 (API 29)
β’ No issues found!
I face this error in the following scenario:
- When I run the app for the first time it works perfectly.
- If I press the back button on Android, run the app for the second time then I try to update some document in Firestore, the app crashes.
I'm working with a StreamBuilder and cloud_firestore: ^0.13.5
Shutting down VM E/AndroidRuntime(32722): FATAL EXCEPTION: main E/AndroidRuntime(32722): Process: br.com.test, PID: 32722 E/AndroidRuntime(32722): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference E/AndroidRuntime(32722): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451) E/AndroidRuntime(32722): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433) E/AndroidRuntime(32722): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025) E/AndroidRuntime(32722): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6) E/AndroidRuntime(32722): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42) E/AndroidRuntime(32722): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6) E/AndroidRuntime(32722): at android.os.Handler.handleCallback(Handler.java:883) E/AndroidRuntime(32722): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime(32722): at android.os.Looper.loop(Looper.java:235) E/AndroidRuntime(32722): at android.app.ActivityThread.main(ActivityThread.java:7441) E/AndroidRuntime(32722): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(32722): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/AndroidRuntime(32722): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)flutter doctor -v
[β] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [versΓΒ£o 10.0.18363.592], locale pt-BR) β’ Flutter version 1.12.13+hotfix.9 at C:\src\flutter β’ Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700 β’ Engine revision af51afceb8 β’ Dart version 2.7.2 [β] Android toolchain - develop for Android devices (Android SDK version 29.0.3) β’ Android SDK at C:\Users\hudso\AppData\Local\Android\sdk β’ Android NDK location not configured (optional; useful for native profiling support) β’ Platform android-29, build-tools 29.0.3 β’ Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java β’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) β’ All Android licenses accepted. [β] Android Studio (version 3.6) β’ Android Studio at C:\Program Files\Android\Android Studio β’ Flutter plugin version 45.1.1 β’ Dart plugin version 192.7761 β’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) [β] Connected device (2 available) β’ XT1033 β’ [I REMOVED IT] β’ android-arm β’ Android 5.1 (API 22) β’ ASUS Z01RD β’ [I REMOVED IT] β’ android-arm64 β’ Android 10 (API 29) β’ No issues found!
https://github.com/FirebaseExtended/flutterfire/issues/2390#issuecomment-618591127
@ZatacaSystems thank you for your comment.
Unfortunately If I downgrade to 0.13.1 version, I will get back to others issues.
Now I'm using 0.13.4 version. It's working for now.
i have same problem cloud_firestore: ^0.13.5 version
@ZatacaSystems thank you for your comment.
Unfortunately If I downgrade to 0.13.1 version, I will get back to others issues.
Now I'm using 0.13.4 version. It's working for now.
Can you confirm that 0.13.4 doesn't have this issue?
@ZatacaSystems thank you for your comment.
Unfortunately If I downgrade to 0.13.1 version, I will get back to others issues.
Now I'm using 0.13.4 version. It's working for now.Can you confirm that 0.13.4 doesn't have this issue?
I came back to that version got the same problem
I had same problem cloud_firestore: ^0.13.5.
I solved the problem this way.
class MainApp extends StatefulWidget {
@override
_MainAppState createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
var _listener;
@override
void initState() {
super.initState();
_listener = _userRef.document("data").snapshots().listen((snapshot) {
// some code
});
}
Future removeListener() async {
if (_listener != null) {
await _listener.cancel();
print("user _listener cancel");
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
removeListener().then((value) {
print("cancel done");
SystemNavigator.pop();
});
},
child: // some view
}
}
I think, we need to cancel the listener, before push the back button.
ΩI have similar issue and I using 0.13.5
the scenario that happened with me is
in production mode and it's happened once time and don't happened if I try same action I have did , so when try add item in firebase it's crashing and if return try same item in same condition maybe didn't crashed but I have cashed these issues.
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent (CloudFirestorePlugin.java:451)
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent (CloudFirestorePlugin.java:433)
com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2 (com.google.firebase:firebase-firestore@@21.3.0:1025)
com.google.firebase.firestore.Query$$Lambda$3.onEvent (Unknown Source:6)
com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0 (com.google.firebase:firebase-firestore@@21.3.0:42)
com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run (Unknown Source:6)
android.os.Handler.handleCallback (Handler.java:873)
android.os.Handler.dispatchMessage (Handler.java:99)
com.google.android.gms.internal.tasks.zzb.dispatchMessage (com.google.android.gms:play-services-tasks@@17.0.2:6)
android.os.Looper.loop (Looper.java:214)
android.app.ActivityThread.main (ActivityThread.java:7156)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
same error here is my stack trace,
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void d.a.b.a.i.a(java.lang.String, java.lang.Object)' on a null object reference
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.a (CloudFirestorePlugin.java:33)
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.a (CloudFirestorePlugin.java:2)
com.google.firebase.firestore.Query.a (Query.java:27)
com.google.firebase.firestore.Query$$Lambda$3.a (Query.java:6)
com.google.firebase.firestore.core.AsyncEventListener.a (AsyncEventListener.java:6)
com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run (AsyncEventListener.java:6)
android.os.Handler.handleCallback (Handler.java:883)
android.os.Handler.dispatchMessage (Handler.java:100)
android.os.Looper.loop (Looper.java:237)
android.app.ActivityThread.main (ActivityThread.java:7857)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1076)
i have gone down to 0.13.1 and will test to make sure that i dont get that error, unfortunately this is a new app so i dont know when this was introduced since i started with 0.13.5. It works 95% of the time and then out of the blue the app dies, you start it back up and everything works again even the thing that made it crash. also FYI this happens on a delete, add, update and even on the remote phone that has Streambuilders for the data that is being changed. Sometimes just deleting a list item on my phone crashes my wife's phone.
update
I have not had a crash yet after downgrading the library. Will keep updated
0.13.4 is also fine for my usecase also no crashes thusfar
I also downgraded cloud_firestore to 0.13.4+2 few days ago and no issues so far
Does anyone have a Map of data which contains whatever is causing the pointer exception?
this is also happening to our app, here's the stacktrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451)
at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433)
at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@21.3.0:1025)
at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6)
at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@21.3.0:42)
at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Sending signal. PID: 18109 SIG: 9
we are using the cloud_firestore: 0.13.6.
steps to reproduce: We have a setDocument transaction being run whenever a button is clicked. When the app starts clean, executing the transaction is not crashing the app, but it only crashes whenever we exit the app by back-button and then we come back to the app and execute this transaction.
In concrete, this crashes when we call Transaction::set(...), and interestingly the transaction does complete successfully each and every time this crashes.
_(similar steps described by https://github.com/FirebaseExtended/flutterfire/issues/2390#issuecomment-622963868)_
Using the steps mentioned by @carloxavier above I managed to reproduce the issue 100% of the time. All you have to do is exit the app using the back button on Android, and on resume trigger a firestore write. In my case, I have a toggle button on the home screen that does a firestore update.
Downgrading to cloud_firestore: 0.13.4+2 did not help for me for some reason.
It's quite scary that this bug has been opened for more than a month and there's been little official support.
My crash-rate is around 5% because of this bug according to Crashlytics and I'm getting customer complaints and bad reviews.
Please treat this with urgency. I'm happy to help if you need anything else from me.
hey I just found that the crash has actually been solved a few days ago on a fork but it hasn't been merged: https://github.com/lidongze91/flutterfire/commit/a2f5abf7d2a6cbb78d0f2f51665c98e49bb378af
we just need to be a bit patient. In the meanwhile we can use cloud_firestore: 0.13.4+2, remember to clean the build after you pub get, worth trying in case you still experience the issue @andcea
@carloxavier thanks for that.
I can confirm that fix is working. I've tested that package directly by: (wouldn't recommend this for production)
cloud_firestore:
git:
url: git://github.com/lidongze91/flutterfire.git
path: packages/cloud_firestore/cloud_firestore
ref: bb5683a
This bug is annoying me a lot. Lot of crash issues reported because of this error. I downgraded the Firestore version 0.13.4 but still the issue persists. Any idea when this will be merged to the Master branch ?
Most helpful comment
@carloxavier thanks for that.
I can confirm that fix is working. I've tested that package directly by: (wouldn't recommend this for production)