How to pass a complex data structure in a callback from an AAR (Kotlin)

I have written an AAR in Kotlin, which has a function that: takes a list of BLE devices also takes a list of messages (byte arrays) and tries to send all the messages to all the devices - at the end it has a map where the key is the MAC of the devie and the entry is a (sorry it's complicated) List of Pairs of responses - the first item in each pair denotes the result of the message sent as a special results class (has possibilities like success, fail, etc) and the second part of the pair is the response byte array from the BleDevice (or null if there was none) So the function looks like this: fun writeToDevicesList(context : Context, bleDevicesList: ArrayList, sendingMap: MutableMap, writingCallback: (MutableMap) -> Unit) { var resultsMap : MutableMap = LinkedHashMap() // do a lot of stuff filling up the results map writingCallback?.let { it(resultsMap) } } So anyway, in the project which has this aar code, I have a test app which calls this function and all the data comes through fine...It's a whole load of replies, success, fails, and all the byteArrays of the results that came in - all fine Then I build it into an AAR and use the same function in the same way in another project There's loads of logging, so I can see that the messages are sent, and replies come into the aar code filling up my map with useful information - the callback is called and my app receives back a Map which contains the right number of entries (as the aar produced). The keys are all there (they match the MAC ids of the devices I tried to send to) but for some reason the lists (while they have the right number of entries...it can vary per device) always show the result is a fail and the byte arrays are null So I am worried that passing such a complex datatype doesn't work through an AAR, although i have not seen that in the documentation I read - maybe someone can point me to it. I read some questions like this which say that if passing from activity to activity one should use serialization - would this work better? Any suggestions might help Thanks

How to pass a complex data structure in a callback from an AAR (Kotlin)

I have written an AAR in Kotlin, which has a function that:

  • takes a list of BLE devices
  • also takes a list of messages (byte arrays) and tries to send all the messages to all the devices - at the end it has a map where the key is the MAC of the devie and the entry is a (sorry it's complicated) List of Pairs of responses - the first item in each pair denotes the result of the message sent as a special results class (has possibilities like success, fail, etc) and the second part of the pair is the response byte array from the BleDevice (or null if there was none) So the function looks like this:
fun writeToDevicesList(context : Context,
                           bleDevicesList: ArrayList,
                           sendingMap: MutableMap>>,
                           writingCallback: (MutableMap>>) -> Unit) {
    var resultsMap : MutableMap>> = LinkedHashMap()
    // do a lot of stuff filling up the results map
    writingCallback?.let {
        it(resultsMap)
    }
}

So anyway, in the project which has this aar code, I have a test app which calls this function and all the data comes through fine...It's a whole load of replies, success, fails, and all the byteArrays of the results that came in - all fine

Then I build it into an AAR and use the same function in the same way in another project

There's loads of logging, so I can see that the messages are sent, and replies come into the aar code filling up my map with useful information - the callback is called and my app receives back a Map which contains the right number of entries (as the aar produced). The keys are all there (they match the MAC ids of the devices I tried to send to) but for some reason the lists (while they have the right number of entries...it can vary per device) always show the result is a fail and the byte arrays are null

So I am worried that passing such a complex datatype doesn't work through an AAR, although i have not seen that in the documentation I read - maybe someone can point me to it.

I read some questions like this which say that if passing from activity to activity one should use serialization - would this work better?

Any suggestions might help

Thanks