Red lines in Android Studio with Firebase

筅森魡賤 提交于 2019-12-25 08:04:05

问题


I am trying to connect Android Studio with Firebase and I have some red lines and I don't know why. I am following instruction from this tutorial : https://www.youtube.com/watch?v=tOn5HsQPhUY

Could someone please tell me if I am doing something wrong and what?

Here is a picture of this


回答1:


the Problem is that these commands are from an older firebase Version. I recommend to take a look at the docs here:https://firebase.google.com/docs/database/android/start/

Try this code :

private DatabaseReference mRef;

mRef = FirebaseDatabase.getInstance().getReference();



回答2:


You forgot to add dependencies for Firebase and maybe you forgot to take the latest Google Repository.

Place your specific dependency:

compile 'com.google.firebase:firebase-messaging:9.6.0'



回答3:


Add import com.firebase.client.Firebase; in class and add compile 'com.firebase:firebase-client-android:2.5.0' in app (build.gradle)




回答4:


Import the following:

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;


来源:https://stackoverflow.com/questions/40829062/red-lines-in-android-studio-with-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!