Android Question [B4A] Class not found

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

My application One B4j and One B4A. B4j publish MqttData to Broker. B4A Subscribe from Broker. B4a always give me a exception as following image when B4A received new message ?

Class not found: b4j.example.mqttcomp$_mqttdata, trying: b4a.example.mqttcomp$_mqttdata

RandomAccessFile B4A=v2.1 B4J=V2.2

qa12.png
B4A code
B4X:
Sub Process_Globals
    Type MqttData (topic As String,value As String,status As String,happen As Long)  <<---
End Sub

Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
    Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)    <<------ Exception
    If Topic = "all/connect" Or Topic = "all/disconnect" Then
        'new client has connected or disconnected
        Dim newUser As String = receivedObject     
    Else if Topic = "all/users" Then
        Dim newUsers As List = receivedObject
        CallSubDelayed2(Chat, "NewUsers", newUsers) 'this will start the chat activity if it wasn't started yet.
    Else if Topic.IndexOf("iot/plc1/")>0 Then
        Dim m As MqttData = receivedObject
        Log("topic" & Topic & "," & m)
        CallSubDelayed2(Chat, "NewMessage",m)
    End If
     
End Sub
B4J code
B4X:
Sub Class_Globals
    Type MqttData (topic As String,value As String,status As String,happen As Long)  <<---
    Private mqtt As MqttClient
    Private vParent As Object
    Private vEvent As String
    Private clientId As String
    Private vConnect As Boolean=False
    Private vuser As String = ""
    Private vpassword As String = ""
    Private mytopic As String=""
    Private serializator As B4XSerializator
    Private timer1 As Timer
    Private Queue As List
End Sub

public Sub Publish4(topic As String,data As MqttData)
    If mqtt.Connected Then
        mqtt.Publish2(topic, serializator.ConvertObjectToBytes(data),0,False)   <<---
    End If
End Sub

Sub timer1_tick
    timer1.Enabled=False
    If Connected Then
        If Queue.Size>0 Then
            Dim item As MqttData=Queue.Get(0)
            Publish4(item.topic,item)                      <<---
            Queue.RemoveAt(0)
            Log("mqtt:"&item.topic&","&item.value)
        End If
    End If
    If Queue.Size>0 Then timer1.Enabled=True
End Sub
 
Last edited:

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

B4A will be termanted when B4A get this message. ? How to solve it ?
 
Upvote 0
Top