title: Firebase Error: Expected a List, but got a class java.util.HashMap
body: <p>I have an object called <code>Garage</code> and once I first declare him, it has 4 parameters: <code>garageName</code>,<code>garageId</code>, <code>garageCoordinatorPhone</code>,<code>garageProducts</code>. I upload it to firebase. After some time I update the garage parameter in firebase: <code>garageStocks</code>.
  When I try getting the data out back to <code>Garage</code> class, I get the exeption:</p>
  <blockquote>
  <p>com.google.firebase.database.DatabaseException: Expected a List while deserializing, but got a class java.util.HashMap</p>
  </blockquote>
  <p>I looked at an almost exact question like this at: <a href="https://stackoverflow.com/q/55694354/11388670">Expected a List while deserializing, but got a class java.util.HashMap</a></p>
  <p>But it's answers doesn't make sense to me... I have been able to get the values even with lists of objects(see <code>garageProducts</code>).</p>
  <p>GaragesActivity:</p>
  <pre><code>public class GaragesActivity extends AppCompatActivity {
  
      ArrayList&lt;String&gt; garages = new ArrayList&lt;&gt;();
      DatabaseReference dbReference = FirebaseDatabase.getInstance().getReference();
      RecyclerView rvGarages;
      Button tvGarageEdit;
      TextView tvGarageCoordinator;
      User selectedGarageCoordinator = null;
      boolean isEditable;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_garages);
  
          
          //defines the widgets
          rvGarages = findViewById(R.id.rvGarages);
          tvGarageEdit = findViewById(R.id.tvGarageEdit);
  
          refreshAllGarages();
  
          //defines and sets the toolbar in place.
          Toolbar toolbar = findViewById(R.id.app_bar);
          setSupportActionBar(toolbar);
  
          //defines the back button at the top corner
          ActionBar ab = getSupportActionBar();
          if(ab != null)
              ab.setDisplayHomeAsUpEnabled(true);
  
  
          tvGarageEdit.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //the opposite every press
                  if (isEditable){
                      isEditable = false;
                      tvGarageEdit.setBackgroundColor(getResources().getColor(R.color.colorWritingImportant));
                  }else{
                      isEditable = true;
                      tvGarageEdit.setBackgroundColor(getResources().getColor(R.color.colorLimeGreen));
                  }
              }
          });
      }
      
      private void refreshAllGarages() {
          //reset
          garages.clear();
          GaragesAdapter myAdapter = new GaragesAdapter(GaragesActivity.this, garages);
          rvGarages.setAdapter(myAdapter);
  
          final Dialog myDialog = new Dialog(GaragesActivity.this);
          myDialog.setContentView(R.layout.dialog_progress);
          if(myDialog.getWindow() != null)
              myDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  
          TextView tvAction = myDialog.findViewById(R.id.tvAction);
          tvAction.setText(&quot;טוען...&quot;);
          myDialog.show();
  
          // Read from the database
          Query q = dbReference.child(&quot;מחסנים&quot;).orderByKey();
          q.addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  for (DataSnapshot AllGarages : dataSnapshot.getChildren()) //gets the list of Garages
                  {
                      Garage g = AllGarages.getValue(Garage.class);
                      if(g.getGarageName() != null)
                          garages.add(g.getGarageName());
                  }
                  GaragesAdapter myAdapter = new GaragesAdapter(GaragesActivity.this, garages);
                  rvGarages.setLayoutManager(new GridLayoutManager(GaragesActivity.this,4));
                  myDialog.dismiss();
                  rvGarages.setAdapter(myAdapter);
              }
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
                  throw databaseError.toException(); //Don't ignore errors
              }
          });
  
      }
  }
  </code></pre>
  <p>Garage class:</p>
  <pre><code>public class Garage {
  
      private String garageName;
      private String garageId;
      private String garageCoordinatorPhone;
      private ArrayList&lt;Product&gt; garageProducts;
      private ArrayList&lt;Product&gt; borrowedProducts;
      private ArrayList&lt;Product&gt; damagedProducts;
      private ArrayList&lt;Product&gt; missingProducts;
      private ArrayList&lt;Stock&gt; garageStocks;
  
      public Garage(){}
  
      public Garage(String garageName, String garageCoordinatorPhone, String garageId, ArrayList&lt;Product&gt; garageProducts){
          this.garageProducts = garageProducts;
          this.garageName = garageName;
          this.garageCoordinatorPhone = garageCoordinatorPhone;
          this.garageId = garageId;
      }
  
      public Garage(String garageName, String garageCoordinatorPhone, String garageId, ArrayList&lt;Product&gt; garageProducts, ArrayList&lt;Stock&gt; garageStocks){
          this.garageProducts = garageProducts;
          this.garageStocks = garageStocks;
          this.garageName = garageName;
          this.garageCoordinatorPhone = garageCoordinatorPhone;
          this.garageId = garageId;
      }
  
      public Garage(String garageName, String garageCoordinatorPhone, String garageId, ArrayList&lt;Product&gt; garageProducts, ArrayList&lt;Stock&gt; garageStocks, ArrayList&lt;Product&gt; borrowedProducts){
          this.garageProducts = garageProducts;
          this.garageStocks = garageStocks;
          this.garageName = garageName;
          this.garageCoordinatorPhone = garageCoordinatorPhone;
          this.garageId = garageId;
          this.borrowedProducts = borrowedProducts;
      }
  
      public Garage(String garageName, String garageCoordinatorPhone, String garageId, ArrayList&lt;Product&gt; garageProducts, ArrayList&lt;Stock&gt; garageStocks, ArrayList&lt;Product&gt; borrowedProducts, ArrayList&lt;Product&gt; damagedProducts, ArrayList&lt;Product&gt; missingProducts){
          this.garageProducts = garageProducts;
          this.garageStocks = garageStocks;
          this.garageName = garageName;
          this.garageCoordinatorPhone = garageCoordinatorPhone;
          this.garageId = garageId;
          this.borrowedProducts = borrowedProducts;
          this.damagedProducts = damagedProducts;
          this.missingProducts = missingProducts;
      }
  }
  </code></pre>
  <p>Firebase:</p>
  <pre><code>{
    &quot;173baaa74c0&quot; : {
      &quot;garageCoordinatorPhone&quot; : &quot;0523122548&quot;,
      &quot;garageId&quot; : &quot;173baaa74c0&quot;,
      &quot;garageName&quot; : &quot;רעננה מרכז&quot;,
      &quot;garageProducts&quot; : [ {
        &quot;description&quot; : &quot;אורך 1.7 מטר&quot;,
        &quot;productAmount&quot; : 5,
        &quot;productCategory&quot; : &quot;בנייה מחנאית&quot;,
        &quot;productId&quot; : 201,
        &quot;productName&quot; : &quot;בזנט&quot;
      }, {
        &quot;description&quot; : &quot;נפח 500 סמ'ק&quot;,
        &quot;productAmount&quot; : 5,
        &quot;productCategory&quot; : &quot;כיבוי אש&quot;,
        &quot;productId&quot; : 402,
        &quot;productName&quot; : &quot;מטפים תקינים&quot;
      }, {
        &quot;description&quot; : &quot;אורך 30 ס'מ&quot;,
        &quot;productAmount&quot; : 4,
        &quot;productCategory&quot; : &quot;כלי עבודה&quot;,
        &quot;productId&quot; : 506,
        &quot;productName&quot; : &quot;שפכטל&quot;
      }, {
        &quot;description&quot; : &quot;אורך 30 ס'מ&quot;,
        &quot;productAmount&quot; : 1,
        &quot;productCategory&quot; : &quot;חשמל&quot;,
        &quot;productId&quot; : 323,
        &quot;productName&quot; : &quot;DI&quot;
      }, {
        &quot;description&quot; : &quot;סיר מתכת לטיולים, קוטר 15 ס'מ&quot;,
        &quot;productAmount&quot; : 7,
        &quot;productCategory&quot; : &quot;בישול&quot;,
        &quot;productId&quot; : 127,
        &quot;productName&quot; : &quot;סיר בינוני&quot;
      }, {
        &quot;description&quot; : &quot;&quot;,
        &quot;productAmount&quot; : 1,
        &quot;productCategory&quot; : &quot;חשמל&quot;,
        &quot;productId&quot; : 309,
        &quot;productName&quot; : &quot;מיקרופון&quot;
      } ],
      &quot;garageStocks&quot; : {
        &quot;1610831472776&quot; : {
          &quot;stockFillerPhone&quot; : &quot;0544926410&quot;,
          &quot;stockId&quot; : 1610831472776,
          &quot;stockProducts&quot; : [ {
            &quot;description&quot; : &quot;אורך 1.7 מטר&quot;,
            &quot;productAmount&quot; : 5,
            &quot;productCategory&quot; : &quot;בנייה מחנאית&quot;,
            &quot;productId&quot; : 201,
            &quot;productName&quot; : &quot;בזנט&quot;
          }, {
            &quot;description&quot; : &quot;נפח 500 סמ'ק&quot;,
            &quot;productAmount&quot; : 5,
            &quot;productCategory&quot; : &quot;כיבוי אש&quot;,
            &quot;productId&quot; : 402,
            &quot;productName&quot; : &quot;מטפים תקינים&quot;
          }, {
            &quot;description&quot; : &quot;אורך 30 ס'מ&quot;,
            &quot;productAmount&quot; : 4,
            &quot;productCategory&quot; : &quot;כלי עבודה&quot;,
            &quot;productId&quot; : 506,
            &quot;productName&quot; : &quot;שפכטל&quot;
          }, {
            &quot;description&quot; : &quot;אורך 30 ס'מ&quot;,
            &quot;productAmount&quot; : 1,
            &quot;productCategory&quot; : &quot;חשמל&quot;,
            &quot;productId&quot; : 323,
            &quot;productName&quot; : &quot;DI&quot;
          }, {
            &quot;description&quot; : &quot;סיר מתכת לטיולים, קוטר 15 ס'מ&quot;,
            &quot;productAmount&quot; : 7,
            &quot;productCategory&quot; : &quot;בישול&quot;,
            &quot;productId&quot; : 127,
            &quot;productName&quot; : &quot;סיר בינוני&quot;
          }, {
            &quot;description&quot; : &quot;&quot;,
            &quot;productAmount&quot; : 1,
            &quot;productCategory&quot; : &quot;חשמל&quot;,
            &quot;productId&quot; : 309,
            &quot;productName&quot; : &quot;מיקרופון&quot;
          } ]
        }
      }
    },
    &quot;1740c8d4920&quot; : {
      &quot;garageCoordinatorPhone&quot; : &quot;0544926411&quot;,
      &quot;garageId&quot; : &quot;1740c8d4920&quot;,
      &quot;garageName&quot; : &quot;אשדוד ט'ו&quot;,
      &quot;garageProducts&quot; : [ {
        &quot;description&quot; : &quot;&quot;,
        &quot;productAmount&quot; : 2,
        &quot;productCategory&quot; : &quot;שונות&quot;,
        &quot;productHome&quot; : &quot;173baaa74c0&quot;,
        &quot;productId&quot; : 1102,
        &quot;productName&quot; : &quot;דרבוקות גדולות&quot;
      }, {
        &quot;description&quot; : &quot;נפח 500 סמ'ק&quot;,
        &quot;productAmount&quot; : 2,
        &quot;productCategory&quot; : &quot;כיבוי אש&quot;,
        &quot;productHome&quot; : &quot;173baaa74c0&quot;,
        &quot;productId&quot; : 402,
        &quot;productName&quot; : &quot;מטפים תקינים&quot;
      } ]
    },
    &quot;174534895e0&quot; : {
      &quot;borrowedProducts&quot; : {
        &quot;5f66189e 207aeaca&quot; : [ {
          &quot;description&quot; : &quot;סיר מתכת לטיולים, קוטר 15 ס'מ&quot;,
          &quot;productAmount&quot; : 1,
          &quot;productCategory&quot; : &quot;בישול&quot;,
          &quot;productHome&quot; : &quot;173baaa74c0&quot;,
          &quot;productId&quot; : 127,
          &quot;productName&quot; : &quot;סיר בינוני&quot;
        } ]
      },
      &quot;garageCoordinatorPhone&quot; : &quot;0544926410&quot;,
      &quot;garageId&quot; : &quot;174534895e0&quot;,
      &quot;garageName&quot; : &quot;הכפתור&quot;,
      &quot;garageProducts&quot; : [ {
        &quot;description&quot; : &quot;אורך 1.7 מטר&quot;,
        &quot;productAmount&quot; : 23,
        &quot;productCategory&quot; : &quot;בנייה מחנאית&quot;,
        &quot;productHome&quot; : &quot;173baaa74c0&quot;,
        &quot;productId&quot; : 201,
        &quot;productName&quot; : &quot;בזנט&quot;
      }, {
        &quot;description&quot; : &quot;&quot;,
        &quot;productAmount&quot; : 2,
        &quot;productCategory&quot; : &quot;שונות&quot;,
        &quot;productHome&quot; : &quot;173baaa74c0&quot;,
        &quot;productId&quot; : 1102,
        &quot;productName&quot; : &quot;דרבוקות גדולות&quot;
      }, {
        &quot;description&quot; : &quot;נפח 500 סמ'ק&quot;,
        &quot;productAmount&quot; : 1,
        &quot;productCategory&quot; : &quot;כיבוי אש&quot;,
        &quot;productHome&quot; : &quot;173baaa74c0&quot;,
        &quot;productId&quot; : 402,
        &quot;productName&quot; : &quot;מטפים תקינים&quot;
      } ]
    }
  }
  </code></pre>
  <pre><code>enter code here
  </code></pre>