Android Question Error writing/reading kvs with Type vars

Bob Spielen

Active Member
Licensed User
Hi, I need some help...
During execution of:

B4X:
        kvs.Initialize(DirX, "ped")
        kvs.Put("oi", Array(Test))
        Dim DumObj() As Object= kvs.Get("oi")
        Dim ct As TpPedT = DumObj(0)

B4X:
Sub Test As TpPedT
     
    TpPed(0).bxdo=3
    TpPed(0).ende=""
    TpPed(0).fentr=4
    TpPed(0).fpgto=5
    TpPed(0).id=6
    TpPed(0).idnuvem=7
    TpPed(0).regdel=8
   
    Log("tpped(0)"  &  TpPed(0))
   
    Private TPI(5) As TpItemT
    TPI(0).id=2
    TPI(0).qtd=3
    TPI(0).taborig="pizza"
   
    TpPed(0).TpItem =TPI
   
    Return TpPed(0)
     
End Sub

B4X:
    Type TpItemT(id As Int, taborig As String, qtd As Double)
    'Public TpItem(50) As TpItemT  '~358
  
    Type TpPedT(id As Int, idnuvem As Int, fpgto As Int, fentr As Int, bxdo As Int, ende As String, regdel As Int, TpItem(50) As TpItemT )
    Public TpPed(100) As TpPedT  '~357



I get the message:


Error message

Logger connected to: asus ASUS_X008D
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
DateTime.time(DateTime.now) = 23:47:46
~364
~365
idpedidos = 0
keyvaluestore_get (B4A line: 26)
result = ser.ConvertBytesToObject(rs.GetBlob2(0)
java.lang.RuntimeException: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:297)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:357)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:246)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:354)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:112)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:82)
at b4a.example.keyvaluestore._get(keyvaluestore.java:153)
at b4a.example.starter._service_create(starter.java:918)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at b4a.example.starter.onCreate(starter.java:55)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3273)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1617)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:208)
at android.app.ActivityThread.main(ActivityThread.java:6267)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at java.lang.reflect.Field.set(Native Method)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:292)
... 20 more
java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3283)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1617)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:208)
at android.app.ActivityThread.main(ActivityThread.java:6267)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at b4a.example.starter.onCreate(starter.java:55)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3273)
... 8 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:297)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:357)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:246)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:354)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:112)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:82)
at b4a.example.keyvaluestore._get(keyvaluestore.java:153)
at b4a.example.starter._service_create(starter.java:918)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
... 11 more
Caused by: java.lang.IllegalArgumentException: field b4a.example.starter$_tppedt.TpItem has type b4a.example.starter$_tpitemt[], got java.lang.Object[]
at java.lang.reflect.Field.set(Native Method)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:292)
... 20 more
 

Bob Spielen

Active Member
Licensed User
Hello Mr. Erel, thanks a lot for your help...
From yesterday to today I solved the problem changing the "child" Type-var of the "parent" Type var into a Map.....
But now Im trying to send the Type var to a MySQL server in the cloud...... and Im getting a compilation problem (see attached).
Can you indicate where to find a solution to send a Type var to a Blob field in the MySQL? In advance, I thank you very much for that.

PS.: Do you think that a PHP file could do the job of downloading a BLOB field more efficiently? Base64 encode/decode image perhaps?
 
Last edited:
Upvote 0
Top