Android Question [Solved] RandomAccessFile WriteB4XObject Problem


Active Member
Licensed User
Longtime User
Dear All.

This is my first ever question on this forum as I have always managed to find the answer using the wealth of knowledge from previous questions so please be gentle with me!

From this thread:

Erel Says:

The following types are supported by WriteB4XObject:
Lists, Maps, String, primitives, user defined types and arrays. Only arrays of bytes and arrays of objects are supported (in B4A and B4J).
Including combinations of these types (a list that holds maps for example).

Note that if you plan to read user defined types that were written by B4i from B4A or B4J then the types must be declared in the main module.

I have created a Custom Type, however I get the following error when I call raf.WriteB4XObject

java.lang.RuntimeException: java.lang.RuntimeException: Cannot serialize object: (ArrayList) [1, 2, 3]

If I use WriteObject or WriteEncryptedObject it works fine.

I believe this issue is related to my Custom Type containing a List.

Is this behaviour normal?

Attached is a very simple Sample Project which shows the problem.

Many Thanks.


Edit: Also, in case it matters.

B4A Version: 4.30
RandomAccessFile Version: 2.00


    21.3 KB · Views: 248
Last edited:


Active Member
Licensed User
Longtime User
Hi Erel.

Many thanks for your confirmation of this issue.

Are you able to tell me when the next version will be available?


Upvote 0


Well-Known Member
Licensed User
Longtime User
I, too am seeing this problem, I have a map with a type.
Dim MOL As Map
Type LOL(Sort As  Int, Fname As String, SWL As CustomListView)
    Dim Lol As LOL
    Lol.Fname = "SwipeList.swl"
    Lol.Sort = 1
    Lol.SWL = SwipeList
    MOL.Put("SwipeList", Lol)
    MOL.Put("ActiveZXZX", Lol)
    Dim Lol2 As LOL
    Lol2.Fname = "Trash.swl"
    Lol2.Sort = 2
    Lol2.SWL = Trash
    MOL.Put("Trash", Lol2)
    Dim Lol3 As LOL
    Lol3.Fname = "Trash.swl"
    Lol3.Sort = 2
    Lol3.SWL = Trash
    MOL.Put("Archive", Lol3)

    Dim R As RandomAccessFile

        File.Delete(File.DirInternal, "MOLZXZX")
        R.Initialize(File.DirInternal, "MOLZXZX", False)
        R.WriteB4XObject(MOL, 0)

I am guessing it is the CustomListView in the type?
Upvote 0