Firebase "Map while deserializing, but got a class java.util.ArrayList"

I have a partial answer but Frank's expertise is required to explain what is really going on.

Running the posted code with version 9.2.0, I observe that the HashMap for allDevices is stored as a JSON array:

public class DevicesCollection {

    public HashMap<String,Device> allDevices; <-- this is stored as array
    public HashMap<String,Category>  categories;
    int lastId;

This is visible in the JSON posted by Aufa:

{
  "devicesController" : {
    "devices" : {
      "allDevices" : [ { <-- note bracket
        "name" : "",
        "on" : true,
        "port" : 0
      }, {

This appears to happen because the keys for the elements of allDevices are Strings in the form of an integer. This is the code that adds an entry to the map of allDevices:

public void addDevice(String name, int port){
    Device temp = new Device();
    temp.setPort(port);
    temp.setName(name);
    allDevices.put(""+lastId,temp); <-- Note that lastId is an integer
    this.lastId++;
    Global.dbMRoot.child("devicesController").child("devices").child(""+lastId).setValue(allDevices.get(lastId));
}

If this code is modified to use a String key that is not in integer format, for example:

allDevices.put("ID"+lastId,temp);

Then the map is written as a map and can be read using

getValue(DevicesCollection.class);