I am trying to set a transition animation on a fragment before it hides, but I am getting a nullpointerexception. Without the .setCustomAnimation method, the code runs fine and the fragment hides, where is the nullpointer coming from?
public class MainActivity extends AppCompatActivity {
    private TextView mavisTxt;
    private Button testBtn;
    private HeaderNav navigationBar;
    private FragmentManager fm;
    private FragmentTransaction ft;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initVariables();
    }
    private void initVariables() {
        fm = getSupportFragmentManager();
        ft = fm.beginTransaction();
        navigationBar = (HeaderNav)fm.findFragmentById(R.id.navigationBar);
        mavisTxt = (TextView)findViewById(R.id.mavisTxt);
        testBtn = (Button)findViewById(R.id.testBtn);
        testBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                    ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
                    ft.hide(navigationBar)
                    .commit();
                    if(navigationBar.isHidden()) {mavisTxt.setText("navbar is hidden");}
            }
        });
    }
}
Here is the log I am getting :
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.startViewTransition(android.view.View)' on a null object reference
 
    