title: mConstraintSet.clone(mConstraintLayout); Not Working
body: <p>I have a constraintLayout nested inside a ScrollView which is nested inside a drawerLayout as per below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.drawerlayout.widget.DrawerLayout xmlns:android=...[snip]&gt;
  
      &lt;ScrollView
          android:layout_width=...[snip]&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id="@+id/content_frame"
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  </code></pre>
  
  <p>In the constraintLayout I have an imageView with xml as below:</p>
  
  <pre><code>            &lt;ImageView
                  android:id="@+id/remotePokerCard2"
                  android:layout_width="72dp"
                  android:layout_height="88dp"
                  android:layout_marginTop="16dp"
                  android:contentDescription="@string/cardSelectcontent"
                  android:onClick="card2clicked"
                  android:padding="3dp"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.5"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toBottomOf="@+id/noOfPlayersTextView"
                  app:srcCompat="@drawable/pokercard2"
                  tools:visibility="visible" /&gt;
  </code></pre>
  
  <p><strong>GOAL: I am trying to programmatically change my constraintTop_toBottomOf.</strong></p>
  
  <p>From</p>
  
  <pre><code>                app:layout_constraintTop_toBottomOf="@+id/noOfPlayersTextView"
  </code></pre>
  
  <p>To</p>
  
  <pre><code>                app:layout_constraintTop_toBottomOf="@+id/2ndImageView"
  </code></pre>
  
  <p>My Java Class <code>Class2</code> updates the UI every time there is a change in FireStore. <code>Class2</code> is being passed the activity context <code>passedActivity</code> from the parent Activity Class <code>Class1</code>. It is then setting up my ConstraintSet, and passing the <code>mConstraintSet</code> and <code>mConstraintLayout</code> to another Java class <code>Class3</code>.</p>
  
  <p><strong>In Class1</strong></p>
  
  <pre><code>Activity passedActivity = Activity_RemotePoker.this;
  
  callRemotePokerListener.Class2(passedActivity, selectedTeamName, TAG, methodName, true, cardNumber, alreadySelected);
  </code></pre>
  
  <p><strong>In Class2</strong></p>
  
  <pre><code>public void Class2(final Activity passedActivity, final String selectedTeam, final String TAG, final String methodName, final Boolean destroyDBListener, int cardNumber, Boolean alreadySelected){
  
  [snip]
  
                              ConstraintLayout mConstraintLayout = passedActivity.findViewById(R.id.constraintlayout);
                              ConstraintSet mConstraintSet = new ConstraintSet();
                              mConstraintSet.clone(mConstraintLayout);
                              callFastSizing.Class3(initialCount, TAG, passedActivity, cardSizes, mConstraintLayout, mConstraintSet);
  
                          }
                      }
                  }
              });
              }
          }
  </code></pre>
  
  <p><strong>EXPECTED RESULT: I have cloned my Activity_RemotePoker layout to mConstraintSet</strong></p>
  
  <p><strong>ACTUAL RESULT: I keep throwing a null pointer exception when I try to clone the existing constraintLayout of the activity.</strong></p>
  
  <pre><code>mConstraintSet.clone(mConstraintLayout);
  </code></pre>
  
  <p><em>"java.lang.NullPointerException: Attempt to invoke virtual method 'int androidx.constraintlayout.widget.ConstraintLayout.getChildCount()' on a null object reference
          at androidx.constraintlayout.widget.ConstraintSet.clone(ConstraintSet.java:705)"</em></p>
  
  <p><strong>In Class3</strong></p>
  
  <pre><code>public class FastSizing {
  
  public void Class3(int initialCount, String TAG, Activity passedActivity, ArrayList cardSizes, ConstraintLayout mConstraintLayout, ConstraintSet mConstraintSet){
  
  [snip]
  
              cardFastChoice.setVisibility(cardFastChoice.VISIBLE);
              mConstraintSet.connect(cardNumber2.getId(), ConstraintSet.TOP, cardFastChoice.getId(), ConstraintSet.BOTTOM, 24);
              mConstraintSet.applyTo(mConstraintLayout);
          }
      }
  
  }
  </code></pre>