Android application error (Activity Main)
<p>I am facing some problem when I want to run my application (debug) from my smartphone. Here's the error.</p>

<pre><code>09-16 19:18:32.703 15432-15432/com.myApp.Name E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myApp.Name, PID: 15432
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myApp.Name/com.myApp.Name.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528)
    at android.app.ActivityThread.access$800(ActivityThread.java:169)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5552)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
    at android.view.LayoutInflater.createView(LayoutInflater.java:637)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:486)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:400)
    at android.app.Activity.setContentView(Activity.java:2168)
    at com.myApp.Name.MainActivity.onCreate(MainActivity.java:15)
    at android.app.Activity.performCreate(Activity.java:5975)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528) 
    at android.app.ActivityThread.access$800(ActivityThread.java:169) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:194) 
    at android.app.ActivityThread.main(ActivityThread.java:5552) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
    at android.view.LayoutInflater.createView(LayoutInflater.java:611)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:486) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:418) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:400) 
    at android.app.Activity.setContentView(Activity.java:2168) 
    at com.myApp.Name.MainActivity.onCreate(MainActivity.java:15) 
    at android.app.Activity.performCreate(Activity.java:5975) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528) 
    at android.app.ActivityThread.access$800(ActivityThread.java:169) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:194) 
    at android.app.ActivityThread.main(ActivityThread.java:5552) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
    at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)
    at android.support.design.widget.CoordinatorLayout.&lt;init&gt;(CoordinatorLayout.java:182)
    at android.support.design.widget.CoordinatorLayout.&lt;init&gt;(CoordinatorLayout.java:176)
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:611) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:486) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:418) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:400) 
    at android.app.Activity.setContentView(Activity.java:2168) 
    at com.myApp.Name.MainActivity.onCreate(MainActivity.java:15) 
    at android.app.Activity.performCreate(Activity.java:5975) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528) 
    at android.app.ActivityThread.access$800(ActivityThread.java:169) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 
    at android.os.Handler.dispatchMessage(Handler.java:111) 
    at android.os.Looper.loop(Looper.java:194) 
    at android.app.ActivityThread.main(ActivityThread.java:5552) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
09-16 19:18:36.755 15432-15432/com.myApp.Name I/Process: Sending signal. PID: 15432 SIG: 9
</code></pre>

<p>And the code named MainActivity.java :</p>

<pre><code>import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity implements View.OnClickListener{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Set UI layout as the view
        setContentView(R.layout.activity_main);

        //Get a reference to the button in our layout
        final Button buttonPlay = (Button)findViewById(R.id.buttonPlay);
        //Listen for clicks
       buttonPlay.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        //Must be the play button.
        //Create a new Intent object
        Intent i = new Intent(this, GameActivity.class);
        //Start our GameActivity class via the Intent
        startActivity(i);
        // Now shut this activity down
        finish();
    }
}
</code></pre>

<p>How do I solve the problem?</p>

<p>After I commented this line of code:</p>

<pre><code>setContentView(R.layout.activity_main);
</code></pre>

<p>It showed another error on this line: </p>

<pre><code>buttonPlay.setOnClickListener(this);
</code></pre>

<p>If I comment that 2 line of codes, the application runs, but only blank screen appears.</p>

<p>activity_main.xml :</p>

<p>
</p>

<pre><code>&lt;android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"&gt;

    &lt;android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;

&lt;include layout="@layout/content_main" /&gt;

&lt;android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email" /&gt;
</code></pre>

<p></p>

<p>content_main.xml code :</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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.gamecodeschool.c1tappydefender.MainActivity"
tools:showIn="@layout/activity_main"
android:background="@drawable/background"&gt;

&lt;TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:id="@+id/textHighScore"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" /&gt;

&lt;Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/buttonPlay"
    android:layout_marginBottom="60dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="60dp"
    android:layout_marginStart="60dp" /&gt;
</code></pre>

<p></p>