我目前试图使用flutter和firebase实时数据库在一起,但我不断得到这个错误,每当我试图获得或更新数据库。它是工作正常的几天前,但我不小心回滚的变化。
我已经做了
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
name: "main_app",
options: FirebaseOptions(
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "fXXXXXXXXXXXXX",
databaseURL: "XXXXXXXXXXXXXXX",
projectId: "XXXXXXXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXX",
appId: "XXXXXXXXXXXXXXXXXXXXX",
measurementId: "XXXXX"
)
);
错误发生每当我做FirebaseDatabase.instance.ref("/users").get()
我已经尝试了不同的端点来检查是否是问题,但错误很难理解imo
I/RepoOperation( 6096): get for query / falling back to disk cache after error: Client is offline
E/firebase_database( 6096): An unknown error occurred handling native method call Query#get
E/firebase_database( 6096): java.util.concurrent.ExecutionException: java.lang.Exception: Client is offline
E/firebase_database( 6096): at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.0.1:5)
E/firebase_database( 6096): at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.0.1:8)
E/firebase_database( 6096): at io.flutter.plugins.firebase.database.FirebaseDatabasePlugin.lambda$queryGet$8$FirebaseDatabasePlugin(FirebaseDatabasePlugin.java:248)
E/firebase_database( 6096): at io.flutter.plugins.firebase.database.-$$Lambda$FirebaseDatabasePlugin$zohedUhq4ZX8w6dhHgizPHWixGY.call(Unknown Source:4)
E/firebase_database( 6096): at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks@@18.0.1:1)
E/firebase_database( 6096): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/firebase_database( 6096): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/firebase_database( 6096): at java.lang.Thread.run(Thread.java:919)
E/firebase_database( 6096): Caused by: java.lang.Exception: Client is offline
E/firebase_database( 6096): at com.google.firebase.database.connection.PersistentConnectionImpl.lambda$get$1$PersistentConnectionImpl(PersistentConnectionImpl.java:441)
E/firebase_database( 6096): at com.google.firebase.database.connection.-$$Lambda$PersistentConnectionImpl$DHovbqW2nxPacSd_wNZBtpYapws.run(Unknown Source:8)
E/firebase_database( 6096): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/firebase_database( 6096): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/firebase_database( 6096): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
E/firebase_database( 6096): ... 3 more
E/flutter ( 6096): [ERROR:flutter/shell/common/shell.cc(94)] Dart Unhandled Exception: [firebase_database/unknown] java.lang.Exception: Client is offline
E/flutter ( 6096):
E/flutter ( 6096): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 6096): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:367:43)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #3 MethodChannelQuery.get (package:firebase_database_platform_interface/src/method_channel/method_channel_query.dart:74:22)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #4 Query.get (package:firebase_database/src/query.dart:21:27)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): , stack trace: #0 MethodChannelQuery.get (package:firebase_database_platform_interface/src/method_channel/method_channel_query.dart:86:7)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #1 Query.get (package:firebase_database/src/query.dart:21:27)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096):
2条答案
按热度按时间4ktjp1zp1#
您似乎在脱机且该高速缓存中没有数据的情况下调用
get()
。请记住,您必须明确启用Firebase实时数据库的磁盘持久性,然后才能在您离线时从数据库读取数据。您可以通过在应用程序启动时调用
setPersistenceEnabled(true)
,然后再调用任何读/写数据的方法来实现这一点:agxfikkp2#
我所做的一切对我很有效。只是
1.把酒吧打扫干净
1.卸载设备上的应用程序。
1.一种扑击棒