Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.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
';设置值';Android Studio显示错误_Android_Android Studio_Firebase_Firebase Realtime Database - Fatal编程技术网

';设置值';Android Studio显示错误

';设置值';Android Studio显示错误,android,android-studio,firebase,firebase-realtime-database,Android,Android Studio,Firebase,Firebase Realtime Database,我们正在尝试将Firebase连接到Android Studio。前两个步骤用绿色勾号标记,但由于某种原因,当我们试图设置myRef的值时,Android Studio说“无法解析symbol‘setValue’”“设置值”为红色 代码截图: 您需要调用push()为新数据生成唯一的密钥: DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference() mDatabase.push().setValue(

我们正在尝试将Firebase连接到Android Studio。前两个步骤用绿色勾号标记,但由于某种原因,当我们试图设置myRef的值时,Android Studio说“无法解析symbol
‘setValue’
”<代码>“设置值”为红色

代码截图:


您需要调用
push()
为新数据生成唯一的密钥:

DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference() 
mDatabase.push().setValue("Hello, World!");

检查语句
myRef.setValue(“你好,世界!”)放错了位置。它必须在方法体中。将其移动到
onCreate()
onStart()
方法中

DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference() 
mDatabase.push().setValue("Hello, World!");