Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
E/MethodChannel#plugins.flatter.io/firebase_数据库(6299):无法处理方法调用_Firebase_Flutter_Firebase Realtime Database - Fatal编程技术网

E/MethodChannel#plugins.flatter.io/firebase_数据库(6299):无法处理方法调用

E/MethodChannel#plugins.flatter.io/firebase_数据库(6299):无法处理方法调用,firebase,flutter,firebase-realtime-database,Firebase,Flutter,Firebase Realtime Database,我正在尝试向Firebase数据库添加一个简单的文本。我已经使用gmail成功登录,并且工作正常,但是当我尝试添加任何内容时,它会给我以下错误: E/MethodChannel#plugins.flutter.io/firebase_database( 6299): Failed to handle method call E/MethodChannel#plugins.flutter.io/firebase_database( 6299): com.google.firebase.databa

我正在尝试向Firebase数据库添加一个简单的文本。我已经使用gmail成功登录,并且工作正常,但是当我尝试添加任何内容时,它会给我以下错误:

E/MethodChannel#plugins.flutter.io/firebase_database( 6299): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_database( 6299): com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call.
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:103)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:60)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at io.flutter.plugins.firebase.database.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:236)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/firebase_database( 6299):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/flutter ( 6299): lets gooo00000000000
E/flutter ( 6299): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call., null, com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call.
E/flutter ( 6299):  at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:103)
E/flutter ( 6299):  at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@17.0.0:60)
E/flutter ( 6299):  at io.flutter.plugins.firebase.database.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:236)
E/flutter ( 6299):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter ( 6299):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter ( 6299):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter ( 6299):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 6299):  at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter ( 6299):  at android.os.Looper.loop(Looper.java:160)
E/flutter ( 6299):  at android.app.ActivityThread.main(ActivityThread.java:6669)
守则:



    final databaser= FirebaseDatabase.instance.reference();
    
     savePost(){
      databaser.child('cats').set({
      'id':'1',
      'name': 'yes sirr'
      }
    );
      print("lets gooo00000000000");
    
     
    }

final databaser=FirebaseDatabase.instance.reference();
savePost(){
databaser.child('cats').set({
“id”:“1”,
“姓名”:“是的,先生”
}
);
打印(“亿美元”);
}

参见示例 我认为您必须使用
等待Firebase初始化。初始化app(…)
参见示例 我认为您必须使用
wait Firebase.initializeApp(…)
初始化,正如spkersten在中所说,确保在获取数据库实例之前调用
Firebase.initializeApp(…)

如果您已经这样做了,但仍然得到了答案,则可能是您从Firebase控制台下载的
Google Services.json
中缺少数据库URL。如果这是原因,您可以在确保已在控制台中创建数据库后下载更新的
Google Services.json
,然后像以前一样将其添加到您的应用程序中,从而解决问题

有关详细信息,请参阅:

  • (适用于Android)
  • (适用于iOS)
正如spkersten在中所说,确保在获取数据库实例之前调用
Firebase.initializeApp(…)

如果您已经这样做了,但仍然得到了答案,则可能是您从Firebase控制台下载的
Google Services.json
中缺少数据库URL。如果这是原因,您可以在确保已在控制台中创建数据库后下载更新的
Google Services.json
,然后像以前一样将其添加到您的应用程序中,从而解决问题

有关详细信息,请参阅:

  • (适用于Android)
  • (适用于iOS)