title: Error inflating class on custom CheckBoxPreference
body: <p>I created a custom <code>CheckBoxPreference</code> class to prevent the <code>CheckBoxPreference</code> from being clicked when the user clicks on anything else than the CheckBox itself.</p>
  
  <p>It worked perfectly yesterday before leaving but for a strange reason it doesn't work today. The app crashes and i get this error :</p>
  
  <blockquote>
    <p>FATAL EXCEPTION: main Process: ca.qc.gouv.stat.kth, PID: 19543
                                                                         java.lang.RuntimeException: Unable to start activity
    ComponentInfo{ca.qc.gouv.stat.kth/ca.qc.gouv.stat.kth.AppPreferenceActivity}:
    android.view.InflateException: Binary XML file line #24: Error
    inflating class ca.qc.gouv.stat.kth.CustomCheckBoxPreference</p>
  </blockquote>
  
  <p>It crashes on this line in the code :  <code>addPreferencesFromResource(R.xml.preferences);</code></p>
  
  <p>I'm almost sure i did not change anything to the project other than adding a Log.i line to my main activity this morning. I tried to comment this line. Clean the project cache. Refresh Gradle projects. A google search returned me many results on <strong>Error inflating class</strong> and i think there's as many solutions as there's questions asked. It looks like a very generic error.</p>
  
  <p>If i replace my custom <code>CheckBoxPreference</code> in the <code>preferences.xml</code> file by a normal one it works. If i put breakpoints in the class of my custom <code>CheckBoxPreference</code> it doesn't break on them. Looks like the code of the class is never executed. I'm totally lost as i'm 100% positive it was working yesterday.</p>
  
  <p>Here's the custom <code>CheckBoxPreference</code> class i did :</p>
  
  <pre><code>package ca.qc.gouv.stat.kth;
  
  import android.content.Context;
  import android.preference.CheckBoxPreference;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.CheckBox;
  import android.widget.TextView;
  
  public class CustomCheckBoxPreference extends CheckBoxPreference {
      private CheckBoxPreference clickedCheckBoxPreference;
  
      CustomCheckBoxPreference(Context context) {
          super(context);
      }
  
      CustomCheckBoxPreference(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      CustomCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
      CustomCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
          super(context, attrs, defStyleAttr, defStyleRes);
      }
  
      @Override
      protected void onBindView(View view) {
          super.onBindView(view);
  
          clickedCheckBoxPreference = this;
  
          CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox);
          TextView title = (TextView) view.findViewById(android.R.id.title);
  
          title.setSingleLine(false);
  
          view.setOnClickListener(null);
          title.setOnClickListener(null);
  
          checkBox.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  CheckBox clickedCheckBox = (CheckBox) v;
  
                  if (clickedCheckBox.isChecked()) {
                      clickedCheckBoxPreference.setChecked(true);
                  } else {
                      clickedCheckBoxPreference.setChecked(false);
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>Here's the <code>preferences.xml</code> file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:sbp="http://schemas.android.com/apk/res/ca.qc.gouv.stat.kth"&gt;
  
      &lt;EditTextPreference
              android:title="@string/url_title"
              android:key="url"
              android:defaultValue="@string/app_url"
  
      /&gt;
      &lt;EditTextPreference
              android:title="@string/pwd_title"
              android:key="pwd"
              android:defaultValue="@string/app_pwd"
  
      /&gt;
      &lt;ListPreference
              android:title="@string/orientation_title"
              android:key="orientation"
              android:entries="@array/orientation_display"
              android:entryValues="@array/orientation_values"
              android:defaultValue="@string/app_orientation"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
          android:title="@string/progress_title"
          android:key="progress"
          android:defaultValue="@string/app_progress"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/js_title"
              android:key="js"
              android:defaultValue="@string/app_js"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/tts_title"
              android:key="tts"
              android:defaultValue="@string/app_tts"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/clear_cache_title"
              android:key="clear_cache"
              android:defaultValue="@string/app_clear_cache"
              android:disableDependentsState="true"
      /&gt;
      &lt;ListPreference
              android:title="@string/cache_mode_title"
              android:key="cache_mode"
              android:entries="@array/cache_mode_display"
              android:entryValues="@array/cache_mode_values"
              android:defaultValue="@string/app_cache_mode"
              android:dependency="clear_cache"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/clear_history_title"
              android:key="clear_history"
              android:defaultValue="@string/app_clear_history"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/clear_form_title"
              android:key="clear_form"
              android:defaultValue="@string/app_clear_form"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/keep_alive_title"
              android:key="keep_alive"
              android:defaultValue="@string/app_keep_alive"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/viewport_title"
              android:key="viewport"
              android:defaultValue="@string/app_viewport"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/fit_title"
              android:key="fit"
              android:defaultValue="@string/app_fit"
              android:dependency="viewport"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/zoom_support_title"
              android:key="zoom_support"
              android:defaultValue="@string/app_zoom_support"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/zoom_controls_title"
              android:key="zoom_controls"
              android:defaultValue="@string/app_zoom_controls"
              android:dependency="zoom_support"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.SeekBarPreference
              android:key="zoom_default"
              android:title="@string/zoom_default_title"
              android:defaultValue="@string/app_zoom_default"
              sbp:maxValue="100"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/error_back_btn_title"
              android:key="error_back_btn"
              android:defaultValue="@string/app_error_back_btn"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/error_home_btn_title"
              android:key="error_home_btn"
              android:defaultValue="@string/app_error_home_btn"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/restrict_host_title"
              android:key="restrict_host"
              android:defaultValue="@string/app_restrict_host"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/debug_info_title"
              android:key="debug_info"
              android:defaultValue="@string/app_debug_info"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/autocomplete_title"
              android:key="autocomplete"
              android:defaultValue="@string/app_autocomplete"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/adjust_height_title"
              android:key="adjust_height"
              android:defaultValue="@string/app_adjust_height"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.SeekBarPreference
              android:key="adjust_tolerance"
              android:title="@string/adjust_tolerance_title"
              android:defaultValue="@string/app_adjust_tolerance"
              android:dependency="adjust_height"
              sbp:maxValue="100"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/long_click_title"
              android:key="long_click"
              android:defaultValue="@string/app_long_click"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.SeekBarPreference
              android:key="settings_delay"
              android:title="@string/settings_delay_title"
              android:defaultValue="@string/app_settings_delay"
              sbp:maxValue="5"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.SeekBarPreference
              android:key="settings_nb_touch"
              android:title="@string/settings_nb_touch_title"
              android:defaultValue="@string/app_settings_nb_touch"
              sbp:maxValue="10"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/file_access_title"
              android:key="file_access"
              android:defaultValue="@string/app_file_access"
      /&gt;
      &lt;ListPreference
              android:title="@string/js_file_access_title"
              android:key="js_file_access"
              android:entries="@array/js_file_access_display"
              android:entryValues="@array/js_file_access_values"
              android:defaultValue="@string/app_js_file_access"
      /&gt;
      &lt;ca.qc.gouv.stat.kth.CustomCheckBoxPreference
              android:title="@string/content_url_access_title"
              android:key="content_url_access"
              android:defaultValue="@string/app_content_url_access"
      /&gt;
      &lt;ListPreference
              android:title="@string/mixed_content_title"
              android:key="mixed_content"
              android:entries="@array/mixed_content_display"
              android:entryValues="@array/mixed_content_values"
              android:defaultValue="@string/app_mixed_content"
      /&gt;
      &lt;Preference
              android:title="@string/exit_btn_lbl"
              android:key="exit"
      /&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>Targeting api 26, min api 21;</p>