title: findViewById not finding views from relevant activity
body: <p><strong>EDIT: Problem Solved after rebuilding the project.</strong></p>
  
  <p>I am making a app which shares data between two activities.
  Name of two Activites : 1. MainActivity 2.ScorerActivity</p>
  
  <p>When I try to make instance of a TextView object int the ScorerActivity the findViewById method finds the id from the MainActivity layout. It does not find the view which is in the ScorerActivity layout.</p>
  
  <p>MainActivity Java</p>
  
  <pre><code>package com.example.android.badmintonscorer;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button startButton = findViewById(R.id.start_button);
      startButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              EditText player1Name = findViewById(R.id.player1_name);
              String player1 = player1Name.getText().toString();
  
              EditText player2Name = findViewById(R.id.player2_name);
              String player2 = player2Name.getText().toString();
  
              Intent intent = new Intent(MainActivity.this, ScorerActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              intent.putExtra("player1_name", player1);
              intent.putExtra("player2_name", player2);
              startActivity(intent);
          }
      });
  }
  }
  </code></pre>
  
  <p>MainActivity layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   tools:context="com.example.android.badmintonscorer.MainActivity"&gt;
  
  &lt;EditText
      android:id="@+id/player1_name"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"
      android:hint="Name of Player 1"
      android:layout_marginTop="50dp"/&gt;
  
  &lt;EditText
      android:id="@+id/player2_name"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"
      android:hint="Name of Player 2"
      android:layout_marginTop="50dp"/&gt;
  
  &lt;Button
      android:id="@+id/start_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Start"
      android:layout_gravity="center_horizontal"
      android:layout_marginTop="75dp" /&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>ScorerActivity Java</p>
  
  <pre><code>package com.example.android.badmintonscorer;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class ScorerActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_scorer);
  
      TextView player1 = findViewById(R.id.p1name); //Cannot resolve symbol
  }
  }
  </code></pre>
  
  <p>ScorerActivity layout</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#00f921"
  tools:context="com.example.android.badmintonscorer.ScorerActivity"&gt;
  
  &lt;LinearLayout
      android:id="@+id/linearLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"&gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/p1name"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:fontFamily="sans-serif-medium"
              android:gravity="center_horizontal"
              android:padding="16dp"
              android:text="Player 1"
              android:textSize="14sp" /&gt;
  
          &lt;TextView
              android:id="@+id/p1score"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:fontFamily="sans-serif-light"
              android:gravity="center_horizontal"
              android:paddingBottom="24dp"
              android:text="0"
              android:textSize="50sp" /&gt;
  
          &lt;Button
              android:id="@+id/p1plus1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="8dp"
              android:layout_weight="1"
              android:background="#f9bf00"
              android:onClick="pointp1"
              android:text="+1 Point" /&gt;
  
          &lt;Button
              android:id="@+id/p1df"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="8dp"
              android:layout_weight="1"
              android:background="#f9bf00"
              android:onClick="dfp1"
              android:text="Double Fault" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="2dp"
          android:layout_height="match_parent"&gt;
  
          &lt;TextView
              android:layout_width="1dp"
              android:layout_height="match_parent"
              android:textColor="@android:color/darker_gray" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/p2name"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:fontFamily="sans-serif-medium"
              android:gravity="center_horizontal"
              android:padding="16dp"
              android:text="Player 2"
              android:textSize="14sp" /&gt;
  
          &lt;TextView
              android:id="@+id/p2score"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:fontFamily="sans-serif-light"
              android:gravity="center_horizontal"
              android:paddingBottom="24dp"
              android:text="0"
              android:textSize="50sp" /&gt;
  
          &lt;Button
              android:id="@+id/p2plus1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="8dp"
              android:layout_weight="1"
              android:background="#f9bf00"
              android:onClick="pointp2"
              android:text="+1 Point" /&gt;
  
          &lt;Button
              android:id="@+id/p2df"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="8dp"
              android:layout_weight="1"
              android:background="#f9bf00"
              android:onClick="dfp2"
              android:text="Double Fault" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  
  &lt;Button
      android:id="@+id/reset"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_below="@+id/linearLayout"
      android:layout_marginLeft="24dp"
      android:layout_marginStart="24dp"
      android:layout_marginTop="65dp"
      android:background="#f9bf00"
      android:text="Reset" /&gt;
  
  &lt;Button
      android:id="@+id/finish"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignTop="@+id/reset"
      android:layout_centerHorizontal="true"
      android:background="#f9bf00"
      android:text="Finish" /&gt;
  
  &lt;Button
      android:id="@+id/share"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignParentRight="true"
      android:layout_alignTop="@+id/reset"
      android:layout_marginEnd="17dp"
      android:layout_marginRight="17dp"
      android:background="#f9bf00"
      android:text="Share" /&gt;
  
     &lt;/RelativeLayout&gt;
  </code></pre>