title: Android Studio App crashes on run after successful build and apk installation
body: <p>This is the simple java code used by me on login screen. App closes itself after the splash screen which I applied. It doesnt go any further. what to do?</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  EditText username = (EditText)findViewById(R.id.input_email);
  EditText password = (EditText)findViewById(R.id.input_password);
  Button loginButton = (Button) findViewById(R.id.btn_login);
  int counter=3;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main); }
  
  //Login Button Code
  
  public void onBtn(View v){
  if(username.getText().toString().equals("shubham.goyal1210@gmail.com")&amp;&amp;
  (password.getText().toString().equals("shubham")))
  {
  Toast.makeText(this, "Login Success", Toast.LENGTH_LONG).show();}
  else {
  Toast.makeText(this, "Login Failed", Toast.LENGTH_SHORT).show();
  counter--;
  if(counter==0){ loginButton.setEnabled(false); }
  else 
  { 
  Toast.makeText(this, counter+" attempts left", Toast.LENGTH_SHORT).show(); }
  }}
  
  //Sign Up Button Code
  
  public void linkSign(View v){
  Intent intent = new Intent(this, signupActivity.class);
  startActivity(intent);
  }}
  </code></pre>