title: How do I store an object which contains an object to Firestore in Android?
body: <p>I'm connecting to Cloud Firestore from my Android app. I need to save an object; That object contains a number of strings and ints, and also a couple of objects.</p>
  
  <p>So, I have the following (simplified):</p>
  
  <p>A <code>MyColourList</code> object which contains:</p>
  
  <pre><code>String name, description;
  String[] colours;
  </code></pre>
  
  <p>A <code>MyGrid</code> object contains the following:</p>
  
  <pre><code>String name, description;
  int numberOfLinks;
  MyColourList colourList, colourListDefault;
  </code></pre>
  
  <p>I want to save a new <code>MyGrid</code> object to Firestore. The Firestore data structure is as follows:</p>
  
  <pre><code>grids &gt; grid1ID &gt; colourList
                       &gt; name
                       &gt; description
                       &gt; colours
                            &gt; 1
                              &gt; White
                            &gt; 2
                              &gt; Black
                   &gt; colourListDefault
                       &gt; name
                       &gt; description
                       &gt; colours
                            &gt; 1
                              &gt; White
                            &gt; 2
                              &gt; Black
                   &gt; description
                   &gt; name
                   &gt; numberOfLinks
  </code></pre>
  
  <p>To save this without the <code>colourLists</code> I just do this:</p>
  
  <pre><code>Map&lt;String, Object&gt; newGrid = new HashMap&lt;&gt;();
          newGrid.put("name", nameString);
          newGrid.put("description", descriptionString);
          newGrid.put("numberOfLink", num_links);
          databaseRef.collection("grids").add(newGrid);
  </code></pre>
  
  <p>which works fine.</p>
  
  <p>However, when I try to add in the <code>colourLists</code> by doing this:</p>
  
  <pre><code>Map&lt;String, Object&gt; newGrid = new HashMap&lt;&gt;();
          newGrid.put("name", nameString);
          newGrid.put("description", descriptionString);
          newGrid.put("numberOfLink", num_links);
          newGrid.put("colourList", colourList);
          newGrid.put("colourListDefault", colourListDefault);
          databaseRef.collection("grids").add(newGrid);
  </code></pre>
  
  <p>I'm getting the following error and a crash: <code>java.lang.IllegalArgumentException: Invalid data. Unsupported type: myapp.ColourList(found in field colourList)</code></p>
  
  <p>I assume I need to map the colourLists in some way before I do this, but I can't find any examples of that. Can anyone advise me?</p>