title: Android Studio Beginner: Keep Getting NoSuchMethodException for android.graphics.FontFamily. <init> []
body: <p>I keep getting this error whenever I run the application, which crashes every time I interact with it. The problem first occurred after I moved the original TextView around and altered the color and Font Style. I'm not sure why it's happening now, but it didn't happen before. I'm not exactly sure why this error is occurring either. Please help.</p>
  <p>Below is the error message:</p>
  <pre><code>E/TypefaceCompatApi26Impl: Unable to collect necessary methods for class java.lang.NoSuchMethodException
      java.lang.NoSuchMethodException: android.graphics.FontFamily.&lt;init&gt; []
  </code></pre>
  <p>This is the MainActivity class:</p>
  <pre><code>package com.example.exploreroptimizer;
  
  import android.app.ActivityManager;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ProgressBar;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  public class MainActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          final Cleaner cleaner = new Cleaner();
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Button cleanButton = findViewById(R.id.cleanButton);
          final ProgressBar cleanBar = findViewById(R.id.progressBar);
          final TextView progressUpdate = findViewById(R.id.progressUpdate);
          System.out.println(&quot;success&quot;);
  
          cleanButton.setOnClickListener(new View.OnClickListener() {
              @Override
  
              public void onClick(View view) {
                  Thread thread = new Thread() {
                      @Override
                      public void run() {
                          try {
                              final ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
                              ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
                              activityManager.getMemoryInfo(mi);
                              final double a = mi.availMem / 0x100000L;
  
                              cleanBar.setProgress(20);
                              progressUpdate.setText(&quot;Cleaning Ram!&quot;);
                              Thread.sleep(1500);
                              cleanBar.setProgress(40);
  
                              progressUpdate.setText(&quot;Closing Unused Apps!&quot;);
                              Thread.sleep(1500);
                              cleanBar.setProgress(100);
  
                              progressUpdate.setText(&quot;Clearing Cache!&quot;);
                              Thread.sleep(1500);
                              Cleaner.deleteCache(getApplicationContext());
  
                              cleaner.killBackgroundProcesses(getApplicationContext(), getApplicationContext().getPackageManager());
                              cleaner.clearRAM();
  
                              runOnUiThread(new Runnable() {
                                  @Override
                                  public void run() {
  
  
                                      Toast.makeText(getApplicationContext(), &quot;I have closed &quot; + Cleaner.i + &quot; apps, &quot;, Toast.LENGTH_SHORT).show();
  
  
                                  }
                              });
                          } catch (InterruptedException e) {
  
                          }
  
                      }
  
                  };
                  thread.start();
  
              }
          });
      }
  
  
  }
  </code></pre>
  <p>And this is the xml file code for the UI:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;Button
          android:id=&quot;@+id/cleanButton&quot;
  
          android:layout_width=&quot;172dp&quot;
          android:layout_height=&quot;166dp&quot;
          android:background=&quot;@drawable/cleanbutton&quot;
  
          android:fontFamily=&quot;sans-serif&quot;
          android:text=&quot;Clean&quot;
          android:textColor=&quot;#FFFFFF&quot;
          android:textSize=&quot;30sp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;ProgressBar
          android:id=&quot;@+id/progressBar&quot;
          style=&quot;?android:attr/progressBarStyle&quot;
          android:layout_width=&quot;312dp&quot;
          android:layout_height=&quot;382dp&quot;
          android:indeterminate=&quot;false&quot;
          android:max=&quot;0&quot;
          android:progress=&quot;0&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/progressUpdate&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:fontFamily=&quot;cursive&quot;
          android:text=&quot;TextView&quot;
          android:textColor=&quot;#0DB344&quot;
          android:textSize=&quot;18sp&quot;
          android:textStyle=&quot;normal|bold&quot;
          android:typeface=&quot;sans&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/progressBar&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  
  
  </code></pre>