Complete the code to initialize Firebase in your Android app's main activity.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Firebase[1].initializeApp(this)
}You need to call FirebaseApp.initializeApp(this) to initialize Firebase in your app.
Complete the code to add Firebase Analytics to your app.
val analytics = FirebaseAnalytics[1](this)Use FirebaseAnalytics.getInstance(this) to get the Analytics instance.
Fix the error in the Firebase Realtime Database reference code.
val database = FirebaseDatabase.getInstance() val myRef = database.[1]("message")
The correct method to get a database reference is getReference("message").
Fill both blanks to complete the Firebase Cloud Firestore initialization and get a collection reference.
val db = FirebaseFirestore[1]() val usersRef = db.[2]("users")
Use FirebaseFirestore.getInstance() to get Firestore instance and collection("users") to get the collection reference.
Fill all three blanks to complete the Firebase Authentication sign-in with email and password code.
val auth = FirebaseAuth[1]() auth.[2]WithEmailAndPassword(email, password) .addOnCompleteListener(this) { task -> if (task.[3]()) { // Sign in success } else { // Sign in failed } }
Use FirebaseAuth.getInstance() to get the auth instance, then signInWithEmailAndPassword to sign in, and check task.isSuccessful() to know if sign-in succeeded.