1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question FireStore error Sub _onvalue was not found

Discussion in 'Android Questions' started by gregorio_adrian_gimenez, May 27, 2019.

Tags:
  1. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed 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

    Code:
    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","gga@gmail.com")
        
            
    Dim base_usuarios As Map
            base_usuarios.Initialize
            base_usuarios.Put(
    "usuarios", registro_usuario)
            
            usuarios.add(registro_usuario)
        
    End If
        
        
    End Sub





    regards
     
  2. DonManfred

    DonManfred Expert Licensed User

    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)

    Code:
    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: May 27, 2019
  3. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Code:
    usuarios.Initialize("yoursubname","usuarios","usuarios")
     
  4. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed User

    Thank you surely I do not know anything. Where is there a tutorial to understand the basics?
     
  5. DonManfred

    DonManfred Expert Licensed User

  6. gregorio_adrian_gimenez

    gregorio_adrian_gimenez Active Member Licensed 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
     
  7. DonManfred

    DonManfred Expert Licensed User

    Please create a new thread for any new question/issue.
    Makle sure to upload a small project which shows the issue.

    What is line 548?
     
  8. DonManfred

    DonManfred Expert Licensed User


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

    Code:
    Sub usuarios_onValue(success As Boolean, value As Object)
        
    Log($"usuarios_onValue(${success},${value})"$)
    End Sub
     
    Last edited: May 28, 2019
  9. DonManfred

    DonManfred Expert Licensed User

    I checked the code: the value inside the Event onValue from the Collectionreference is a DocumentReference.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice