Sub sendCommand(msg As String)
Dim Packet As UDPPacket
data = msg.GetBytes("UTF8")
Packet.Initialize(data,GetBroadcastAddress,52829)
For i = 1 To 3
UDPSocket1.Send(Packet)
Wait For (CheckResponse(2000)) Complete (Success As Boolean)
If Success Then Exit
Next
If i = 4 Then
Log("Failed to send...")
End If
End Sub
It works great in Debug mode. But in Release i get an error:
java.lang.RuntimeException: java.lang.ClassCastException: anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$MyDatagramPacket cannot be cast to anywheresoftware.b4a.objects.SocketWrapper$UDPSocket
Only UDPSocket1.Send(Packet) cause the error.
The code after will not be reached because of the error.
The code itself is ok i think. because it works completely in debug mode.
Sub sendCommand(msg As String)
data = msg.GetBytes("UTF8")
For i = 1 To 3
Dim Packet As UDPPacket
Packet.Initialize(data,GetBroadcastAddress,52829)
UDPSocket1.Send(Packet)
Wait For (CheckResponse(2000)) Complete (Success As Boolean)
If Success Then Exit
Next
If i = 4 Then
Log("Failed to send...")
End If
End Sub
if possible upload you project (strip anything out not needed, but leave enough to repeat the issue). Do a Tools->Clean Project, then File->Export as Zip
java.lang.RuntimeException: java.lang.ClassCastException: anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$MyDatagramPacket cannot be cast to anywheresoftware.b4a.objects.SocketWrapper$UDPSocket
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1663)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassCastException: anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$MyDatagramPacket cannot be cast to anywheresoftware.b4a.objects.SocketWrapper$UDPSocket
at de.awtrix.starter$ResumableSub_CheckResponse.resume(starter.java:224)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1661)
... 7 more