Android Question FireStore error Sub _onvalue was not found

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hi!

I was able to insert a record in the Firestore database. when you insert it, this error is generated and the program closes. It would seem that a function is raised but I do not know how to implement it.
Error:
java.lang.Exception: Sub _onvalue was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

code insert,
works fine

B4X:
Sub Enviar_registro_Click
    
    fs.Initialize("Firestore",True)
    Dim usuarios As CollectionReference
    usuarios.Initialize("","usuarios","usuarios")
    If fs.isInitialized Then
    
        
        Dim  loc  As  GeoPoint
        loc.Initialize ( 50.8 , 6.44 )
    
        
        
        Dim registro_usuario As Map
        registro_usuario.Initialize
        registro_usuario.Put("Alias","gregorioooo")
        registro_usuario.Put("Apellido","gregorio")
        registro_usuario.Put("Areas","Noqui")
        registro_usuario.Put("Nombre","Gimenez")
        registro_usuario.Put("geo",loc)
        registro_usuario.Put("mail","[email protected]")
    
        Dim base_usuarios As Map
        base_usuarios.Initialize
        base_usuarios.Put("usuarios", registro_usuario)
        
        usuarios.add(registro_usuario)
    End If
    
    
End Sub






regards
 

DonManfred

Expert
Licensed User
Longtime User
usuarios.Initialize("","usuarios","usuarios")
You did not set a eventprefix (1st par)!!!
Asuming you use
usuarios

here then the eventsignature should be usuarios_onValue (check the example for the correct signature)

B4X:
Sub usuarios_onValue(success As Boolean, value As Object)
    Log($"Driver_onValue(${success},${value})"$)
    Dim docsnap As DocumentSnapshot = value
    Log("DocumentID: "&docsnap.Id)
    Dim data As Map = docsnap.Data
    Log(data)
End Sub

I suggest to get familar with the B4X language first. Seems like you do not know the basics at all. Or how to add a eventsub
 
Last edited:
Upvote 0

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hi, now this error

Driver_onValue(true,com.google.firebase.firestore.DocumentReference@13a8251f)
main_usuarios_onvalue (java line: 548)
java.lang.ClassCastException: com.google.firebase.firestore.DocumentReference cannot be cast to com.google.firebase.firestore.DocumentSnapshot
at com.aeropuerto.myapp.main._usuarios_onvalue(main.java:548)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)


sorry for not knowing what happens

regards
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Sub usuarios_onValue(success As Boolean, value As Object)
Log($"Driver_onValue(${success},${value})"$)
Dim docsnap As DocumentSnapshot = value
Log("DocumentID: "&docsnap.Id)
Dim data As Map = docsnap.Data
Log(data)
End Sub


try to remove the object inside. only use log to see what is coming as "Value"....

B4X:
Sub usuarios_onValue(success As Boolean, value As Object)
    Log($"usuarios_onValue(${success},${value})"$)
End Sub
 
Last edited:
Upvote 0
Top