title: Opening a Fragment from a BottomSheetDialogFragment - Android Studio Java
body: <p>I am trying to open a fragment from a Bottom Sheet, however when I run the app and click the button in the Bottom Sheet that is supposed to do this, the app crashes.</p>
  <p>The Build failure that shows up is:</p>
  <blockquote>
  <p>Deprecated Gradle features were used in this build, making it
  incompatible with Gradle 7.0. Use '--warning-mode all' to show the
  individual deprecation warnings.</p>
  </blockquote>
  <p>How can I open a fragment from my Bottom Sheet. Thank you in advance!</p>
  <pre><code>import android.os.Bundle;
  import android.text.Html;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.Toast;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.core.view.GravityCompat;
  import androidx.drawerlayout.widget.DrawerLayout;
  import androidx.fragment.app.Fragment;
  import androidx.fragment.app.FragmentManager;
  import androidx.fragment.app.FragmentTransaction;
  
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
  
  public class BottomSheet extends BottomSheetDialogFragment  {
  Button flood
  FragmentManager fragmentManager;
  FragmentTransaction fragmentTransaction;
  
  
  public BottomSheet() {
  
  }
  
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.bottom_sheet, container, false);
      flood = v.findViewById(R.id.flood);
     
  
  
      flood.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              EmergencyContacts nextFrag= new EmergencyContacts();
              getActivity().getSupportFragmentManager().beginTransaction()
                      .replace(R.id.fragment_container, nextFrag, &quot;findFragment&quot;)
                      .addToBackStack(null)
                      .commit();
          }
      });
      return v;
  } }
  </code></pre>
  <p>Gradle Dependencies:</p>
  <pre><code>dependencies {
  implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
  implementation 'androidx.appcompat:appcompat:1.1.0'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  implementation 'com.google.firebase:firebase-firestore:17.1.2'
  implementation 'com.android.support:multidex:1.0.3'
  implementation 'com.google.android.gms:play-services-maps:17.0.0'
  implementation 'com.google.android.material:material:1.3.0-alpha02'
  
  
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test.ext:junit:1.1.1'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  }
  </code></pre>