问题
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