Android - EditText set error : im trying to set error on my edit text if the user perssed the login button without fill the text fields. I have tried several codes , but nothing helped. The application was crashing every time i ran it.

**this this is the code**

        public class LoginFragment extends Fragment {

    private ProgressDialog progressDialog;
    private FirebaseAuth firebaseAuth;
    EditText email,password;
    Button login;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_login_fragment, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        firebaseAuth = firebaseAuth.getInstance();

        progressDialog = new ProgressDialog(getActivity());

        login = (Button)getActivity().findViewById(R.id.loginBtn);
        email = (EditText)getActivity().findViewById(R.id.regEmailEt);
        password = (EditText)getActivity().findViewById(R.id.regPasswordEt);


        login.setOnClickListener(new View.OnClickListener() {
            String email1;
            String password1;
                @Override
                public void onClick(View v) {
                    if(email.getText().length() == 0){
                        email.setError("Please enter your email");
                    }
                    if(password.getText().length() == 0){
                        password.setError("Please enter your password");
                    }

                         email1 = email.getText().toString();
                         password1 = password.getText().toString();

                    progressDialog.setMessage("Processing...");
                    progressDialog.show();


                       FirebaseAuth.getInstance().createUserWithEmailAndPassword(email1, password1)
                               .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                                   @Override
                                   public void onComplete(Task<AuthResult> task) {
                                       if (task.isSuccessful()) {
                                           startActivity(new Intent(getActivity(), MainActivity.class));
                                           progressDialog.dismiss();
                                       }
                                   }
                               }).addOnFailureListener(new OnFailureListener() {
                           @Override
                           public void onFailure(Exception e) {
                               Toast.makeText(getActivity(), "Error:" + e.getMessage(), Toast.LENGTH_LONG).show();
                               progressDialog.dismiss();
                           }
                       });
                   }

            });

           }
       }

when the login button pressed it should active the setOnClickListener.
there i want to check if the text fields are empty, if they are so i want to setError in the textEdit. else , i want it to continue. 
I'm pretty sure that my code is wrong, so i need your advise guys.
