B4J Question [SOLVED] Cannot initialize B4XBytesBuilder in NONUI app

max123

Well-Known Member
Licensed User
Longtime User
Hi all,

I can Initialize B4XBytesBuilder in UI apps, but here for some strange reasons the inizializer line return an error on NONUI (Server) app:
B4X:
Dim bBuilder As B4XBytesBuilder
bBuilder.Initialize ' <-- ERROR HERE
bBuilder.Clear
the log show an IllegalArgumentException, wrong number of arguments.
Can someone help me to know because this happen ?
Thanks

Log:
 

Daestrum

Expert
Licensed User
Longtime User
Just tried it in a server app, no error messages at all.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Thanks for reply @Daestrum , do you mean NONUI app ?
I have error here, not while compile, while execute it.
I tried it in Debug mode.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
You are perfectly right, this in a new NONUI project works to me too:
B4X:
Sub Process_Globals
    Private bBuilder As B4XBytesBuilder
End Sub

Sub AppStart (Args() As String)
    bBuilder.Initialize
    bBuilder.Clear
   
    Log("PASSED")
   
    StartMessageLoop
End Sub

But for same strange reasons it will not works on my main project.

May some incompatibility with other libraries ?
Now I will start to try importing all libraries like in my main project, recompile and execute again...
Some tips?

Thanks
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
One thing I did notice, although it gave no error message, if you place the initialise after the StartMessageLoop it doesn't appear to initialise the b4xbytesbuilder.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Thanks both @Erel and @Daestrum for replies,

Probably I've found a mistake, this seem related to one my class that I compiled as library with old B4J release.

I found it by starting from a blank project, then add one by one the libraries I've used in main project, eveey time I add a library, I execute it again. This may can useful for peoples that had the same problem.

Now I recompiled my class and the error in the B4XByteBuilder initializer disappeared.

This class I recompiled is an Encryption class I wrote to exchange data (over socket) to/from Android, ESP32 and Raspberry, I had a lot of difficulties making it to work because different encoding on B4X and C++, finally after I wrote a lots of non working subs to encode/decode, I just end up to shift some characters that is not a true encryption. But this is another question, eventually I will start a new thread to discuss it.

Thanks again, I will put SOLVED in the thread title.
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
One thing I did notice, although it gave no error message, if you place the initialise after the StartMessageLoop it doesn't appear to initialise the b4xbytesbuilder.
The initializer is before of StartMessageLoop that is just the last line in the App Start sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
if you place the initialise after the StartMessageLoop it doesn't appear to initialise the b4xbytesbuilder.
The code execution stops once it reaches the StartMessageLoop. The meaning of this call is that the thread starts a message loop. Messages = events. It only exits the message loop after a call to StopMessageLoop (which actually sends a message to the messages queue).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…