当我添加这个 demoRef = FirebaseDatabase.getInstance().getReference().child("txt");我的应用程序崩溃,当我删除它时,应用程序工作可以有人帮助我。我尝试了很多方法,比如更改数据库的版本,但没有任何效果,我花了 3 多周的时间没有任何解决这是我的主要活动公共类 MainActivity 扩展 Activity {private HashMap <String,Object>map=new HashMap();private Button send;private EditText edit;private DatabaseReference demoRef;@Overrideprotected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); FirebaseApp.initializeApp(this); demoRef = FirebaseDatabase.getInstance().getReference().child("txt"); send=findViewById(R.id.mainButton1); edit=findViewById(R.id.mainEditText1);}}这是我的构建dependencies { //compile 'com.google.firebase:firebase-database:+' compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.firebase:firebase-database:16.0.1' compile 'com.google.firebase:firebase-core:16.0.1'}apply plugin: 'com.google.gms.google-services'
2 回答
qq_笑_17
TA贡献1818条经验 获得超7个赞
消除
FirebaseApp.initializeApp(this);
让参考像这样
private HashMap <String,Object>map=new HashMap();
private Button send;
private EditText edit;
private DatabaseReference demoRef;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
demoRef = FirebaseDatabase.getInstance().getReference().child("txt");
send=findViewById(R.id.mainButton1);
edit=findViewById(R.id.mainEditText1);
}
并确保您在清单中具有 INTERNET 权限
添加回答
举报
0/150
提交
取消