Add button crashes the app
<p>I am trying to add a simple button to my application but I got the error below:</p>

<blockquote>
  <p>Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference</p>
</blockquote>

<p>Here is my Java code:</p>

<pre><code>final Button settings = (Button) findViewById(R.id.settings);
settings.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent i = new Intent(getBaseContext(), Settings.class);
        startActivity(i);
    }
});
</code></pre>

<p>Here is my XML:</p>

<pre><code>&lt;Button
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:id="@+id/settings"
    android:src="@drawable/settings"
    android:background="@drawable/settings"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="70dp"
    android:layout_marginRight="10dp" /&gt;
</code></pre>

<p>By the way, this is the second button I have tried to add. The first one worked fine.</p>