title: android.view.InflateException: Binary XML file line #0: Error inflating class Button
body: <p>I am following a course on Audacity, and decided to type out all the code, but then I run into an error when I try run the app.</p>
  
  <p>I get the following error:</p>
  
  <pre><code>        10-27 19:17:41.871 26679-26679/com.example.vhuhwavho.friendlychat W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41bbec08)
      10-27 19:17:41.871 26679-26679/com.example.vhuhwavho.friendlychat E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.vhuhwavho.friendlychat, PID: 26679
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vhuhwavho.friendlychat/com.example.vhuhwavho.friendlychat.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class Button
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2334)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
      at android.app.ActivityThread.access$900(ActivityThread.java:169)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:146)
      at android.app.ActivityThread.main(ActivityThread.java:5487)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
      at dalvik.system.NativeStart.main(Native Method)
      Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class Button
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
      at com.example.vhuhwavho.friendlychat.MainActivity.onCreate(MainActivity.java:42)
      at android.app.Activity.performCreate(Activity.java:5451)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392) 
      at android.app.ActivityThread.access$900(ActivityThread.java:169) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:146) 
      at android.app.ActivityThread.main(ActivityThread.java:5487) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
      at dalvik.system.NativeStart.main(Native Method) 
      Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
      at android.content.res.TypedArray.getColor(TypedArray.java:327)
      at android.support.v7.widget.TintTypedArray.getColor(TintTypedArray.java:163)
      at android.support.v7.widget.ThemeUtils.getThemeAttrColor(ThemeUtils.java:65)
      at android.support.v7.widget.AppCompatDrawableManager.createDefaultButtonColorStateList(AppCompatDrawableManager.java:584)
      at android.support.v7.widget.AppCompatDrawableManager.getTintList(AppCompatDrawableManager.java:536)
      at android.support.v7.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:53)
      at android.support.v7.widget.AppCompatButton.&lt;init&gt;(AppCompatButton.java:74)
  at android.support.v7.widget.AppCompatButton.&lt;init&gt;(AppCompatButton.java:67)
      at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109)
      at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
      at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
      at com.example.vhuhwavho.friendlychat.MainActivity.onCreate(MainActivity.java:42) 
      at android.app.Activity.performCreate(Activity.java:5451) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392) 
      at android.app.ActivityThread.access$900(ActivityThread.java:169) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:146) 
      at android.app.ActivityThread.main(ActivityThread.java:5487) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
      at dalvik.system.NativeStart.main(Native Method) 
      10-27 19:17:46.696 26679-26679/com.example.vhuhwavho.friendlychat I/Process: Sending signal. PID: 26679 SIG: 9                                                                     
  </code></pre>
  
  <p>Here’s the main activity:</p>
  
  <pre><code>package com.example.vhuhwavho.friendlychat;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.InputFilter;
  import android.text.TextWatcher;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.ListView;
  import android.widget.ProgressBar;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class MainActivity extends AppCompatActivity {
  
      private static final String TAG = "MainActivity";
  
      public static final String ANONYMOUS = "anonymous";
      public static final int DEFAULT_MSG_LENGTH_LIMIT = 1000;
  
      private ListView mMessageListView;
      private MessageAdapter mMessageAdapter;
      private ProgressBar mProgressBar;
      private ImageButton mPhotoPickerButton;
      private EditText mMessageEditText;
      private Button mSendButton;
  
      private String mUsername;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mUsername = ANONYMOUS;
  
          // Initialize references to views
          mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
          mMessageListView = (ListView) findViewById(R.id.messageListView);
          mPhotoPickerButton = (ImageButton) findViewById(R.id.photoPickerButton);
          mMessageEditText = (EditText) findViewById(R.id.messageEditText);
          mSendButton = (Button) findViewById(R.id.sendButton);
  
          // Initialize message ListView and its adapter
          List&lt;FriendlyMessage&gt; friendlyMessages = new ArrayList&lt;&gt;();
          mMessageAdapter = new MessageAdapter(this, R.layout.item_message, friendlyMessages);
          mMessageListView.setAdapter(mMessageAdapter);
  
          // Initialize progress bar
          mProgressBar.setVisibility(ProgressBar.INVISIBLE);
  
          // ImagePickerButton shows an image picker to upload a image for a message
          mPhotoPickerButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  // TODO: Fire an intent to show an image picker
              }
          });
  
          // Enable Send button when there's text to send
          mMessageEditText.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                  if (charSequence.toString().trim().length() &gt; 0) {
                      mSendButton.setEnabled(true);
                  } else {
                      mSendButton.setEnabled(false);
                  }
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
              }
          });
          mMessageEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT)});
  
          // Send button sends a message and clears the EditText
          mSendButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  // TODO: Send messages on click
  
                  // Clear input box
                  mMessageEditText.setText("");
              }
          });
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.main_menu, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>Here’s the <code>activity_main.xml</code> in <code>@layout</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: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.vhuhwavho.friendlychat.MainActivity"&gt;
  
      &lt;ListView
          android:id="@+id/messageListView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_above="@+id/linearLayout"
          android:stackFromBottom="true"
          android:divider="@android:color/transparent"
          android:transcriptMode="alwaysScroll"
          tools:listitem="@layout/item_message"/&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:orientation="horizontal"&gt;
  
          &lt;ImageButton
              android:id="@+id/photoPickerButton"
              android:layout_width="36dp"
              android:layout_height="36dp"
              android:background="@android:drawable/ic_menu_gallery" /&gt;
  
          &lt;EditText
              android:id="@+id/messageEditText"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:layout_weight="1" /&gt;
  
          &lt;Button
              android:id="@+id/sendButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              android:enabled="false"
              android:text="@string/send_button_label"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar"
          style="?android:attr/progressBarStyleLarge"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here’s the <code>item_message.xml</code> in <code>@layout</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginStart="@dimen/activity_horizontal_margin"
                android:orientation="vertical"&gt;
  
      &lt;ImageView
          android:id="@+id/photoImageView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:adjustViewBounds="true" /&gt;
  
      &lt;TextView
          android:id="@+id/messageTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="0"
          android:textAppearance="?android:attr/textAppearanceLarge"
          tools:text="Message" /&gt;
  
      &lt;TextView
          android:id="@+id/nameTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="0"
          android:textAppearance="?android:attr/textAppearanceSmall"
          tools:text="Name" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here’s the <code>button_selector.xml</code> in <code>@drawale</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:color="#999999" android:state_enabled="false"/&gt;
      &lt;item android:color="@color/colorAccent" android:state_enabled="true"/&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Here's the <code>colors.xml</code> in <code>@values</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;color name="colorPrimary"&gt;#FF9800&lt;/color&gt;
      &lt;color name="colorPrimaryDark"&gt;#E65100&lt;/color&gt;
      &lt;color name="colorAccent"&gt;#2E7D32&lt;/color&gt;
      &lt;color name="colorTitle"&gt;#ffffff&lt;/color&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Here's the <code>strings.xml</code> in <code>@values</code>:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;string name="app_name"&gt;Friendly Chat&lt;/string&gt;
      &lt;string name="sign_out"&gt;Sign Out&lt;/string&gt;
      &lt;string name="send_button_label"&gt;Send&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Here’s the <code>styles.xml</code> in <code>@values</code>:</p>
  
  <pre><code>&lt;resources xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;!-- Base application theme. --&gt;
      &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
          &lt;!-- Customize your theme here. --&gt;
          &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
          &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
          &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
  
          &lt;!--&lt;item name="android:colorButtonNormal"&gt;@drawable/button_selector&lt;/item&gt;--&gt;
          &lt;item name="colorButtonNormal"&gt;@drawable/button_selector&lt;/item&gt;
          &lt;item name="android:buttonStyle"&gt;@style/FriendlyButtonStyle&lt;/item&gt;
      &lt;/style&gt;
  
      &lt;style name="FriendlyButtonStyle" parent="Widget.AppCompat.Button"&gt;
          &lt;item name="android:textColor"&gt;@color/colorTitle&lt;/item&gt;
  
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Here's the <code>menu.xml</code> in <code>@menu</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
      &lt;item
          android:id="@+id/sign_out_menu"
          android:title="@string/sign_out"
          app:showAsAction="never"/&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>Here's <code>dimens.xml</code> in <code>@values</code>:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;!-- Default screen margins, per the Android Design guidelines. --&gt;
      &lt;dimen name="activity_horizontal_margin"&gt;16dp&lt;/dimen&gt;
      &lt;dimen name="activity_vertical_margin"&gt;16dp&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Here's <code>(w820dp) dimens.xml</code> in <code>@values</code>:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;!-- Example customization of dimensions originally defined in res/values/dimens.xml
           (such as screen margins) for screens with more than 820dp of available width. This
           would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --&gt;
      &lt;dimen name="activity_horizontal_margin"&gt;64dp&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Please help me solve the error.</p>