0

I am trying to simply get some data I've created mannually in Firebird Realtime Database following the Firebase Assistant on Android Studio (it is an actual copy of the instructions):

   override fun onMapReady(googleMap: GoogleMap) {
        mMap = googleMap
        val database = Firebase.database


        val myRef = database.getReference("ChargePoint") //this is the only item I have edited, since it is from by database

// Read from the database
        myRef.addValueEventListener(object: ValueEventListener() {

            override fun onDataChange(snapshot: DataSnapshot) {
                // This method is called once with the initial value and again
                // whenever data at this location is updated.
                val value = snapshot.getValue<String>()
                Log.d("onDataChange", "Value is: " + value)
            }

            override fun onCancelled(error: DatabaseError) {
                Log.w("onCancelled", "Failed to read value.", error.toException())
            }

        })

However, I am getting this from the line with ValueEventListener:

This class does not have a constructor

Every single example I searched has a "new" clause whenever in Java or the "object:" reference directly in Kotlin. What am I missing? Thanks in advance.

  • Isn't it saying "does not define a no-argument constructor"? – Alex Mamo Jun 10 '22 at 10:45
  • @AlexMamo, this is the exact except I am getting from Android Studio... I mean, it is related to the ValueEventListener – Marcus J S Pereira Jun 10 '22 at 11:11
  • Hey @AlexMamo: that error message seems unlikely from this code, as it's only reading a `String` value not a custom class. Are you sure it's a duplicate? – Frank van Puffelen Jun 10 '22 at 12:50
  • @MarcusJSPereira Can you edit your question (there's a link right under it) to include the exact error message and the complete stack trace (you can get both from the logcat output)? – Frank van Puffelen Jun 10 '22 at 12:50
  • @FrankvanPuffelen Hey puf. The OP said, "is the exact". I'm looking forward to seeing the exact error message and the complete stack trace. If it's different I will reopen it immediately. Thank you! – Alex Mamo Jun 10 '22 at 12:59

0 Answers0