solution to invoking virtual method on a null object reference : <p><strong>Main Activity</strong>
 These are the codes</p>

<pre><code>import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FunfactMainActivity extends AppCompatActivity {
    // Declare our view variables
    private TextView mFactTextView;
    private Button mShowFactButton;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_funfact_main);

        //Assign the views from the layout file to the corresponding variables

        mFactTextView= (TextView) findViewById(R.id.factTextView);
        mShowFactButton= (Button) findViewById(R.id.showFactButton);

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // The button was clicked, so update the fact TextView with a new fact

                String fact = "Ostriches can run faster than horses";
                mFactTextView.setText(fact);
            }
        };
        mShowFactButton.setOnClickListener(listener);
    }
}
</code></pre>

<p><strong>main.xml</strong>
 These are the codes</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.oluwatomisinekpek.funfacts.FunfactMainActivity"
    android:background="@android:color/holo_green_dark"&gt;

    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Did you know?"
        android:id="@+id/textView2"
        android:textSize="20sp"
        android:textColor="#80ffffff" /&gt;

    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Ants stretch when they wake up in the morning."
        android:id="@+id/textView"
        android:layout_below="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="150dp"
        android:textSize="24sp"
        android:textColor="@android:color/white" /&gt;

    &lt;Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Next Fun Fact"
        android:id="@+id/Funfactbutton"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@android:color/white" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p><strong>Logcat</strong></p>

<p>These are the error reports</p>

<pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
</code></pre>

<p>I am a new beginner of android development. So far, i know the basics and learning how to debug an app. I found the crash, but do not know how to go about it.</p>
