Preferences Support Library – SwitchPreference not working

A few days ago Google introduced the Preference Support Library (Link). I’ve just tried to implement it in my application though it seems like it’s not working with SwitchPreferences which is weird because Google states that we can use the same XML-Files as before and explicity says that SwitchPreferences are now available to all API 7+ devices.

Quote (Source)

  • Can I select a particular Android Device Emulator from AVD using Apache Cordova?
  • Navigation Drawer without Actionbar
  • How to get screen width and height
  • Resolved color instead of a resource id
  • Strange behaviour of images in RecyclerView
  • Finding a list of all the android apps on the market
  • […] and add preferences using the same preference XML files
    (, while adding support for elements such as
    SwitchPreference (previously only available on API 14+ devices) to all
    API 7+ devices. […]

    Error message

    java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #4: Error inflating class (not found)SwitchPreference
                at android.os.Handler.dispatchMessage(
                at android.os.Looper.loop(
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(

    Relevant part is obviously Binary XML file line #4: Error inflating class (not found)SwitchPreference.

    Java code

    public class FragmentSettings extends PreferenceFragmentCompat {
        public void onCreatePreferences(Bundle bundle, String s) {


    <?xml version="1.0" encoding="utf-8"?>
    <PreferenceScreen xmlns:android="">
            android:summary="Lorem ipsum dolor sit amet"
            android:title="Lorem ipsum" />

    So basically the question is: Am I doing something wrong or is this indeed a bug of the Preference Support Library?

  • Android - How to pass HashMap<String,String> between activities?
  • Is AsyncTask really conceptually flawed or am I just missing something?
  • Android emulator not starting at all
  • how to calibrate the orientation sensor in android?
  • Android Studio - Emulator - eglSurfaceAttrib not implemented
  • how can I import .apk file of the downloaded file into Eclipse? Do we have this option?
  • One Solution collect form web for “Preferences Support Library – SwitchPreference not working”

    SwitchPreference added in API level 14. if you are using Preferences Support Library v7, you must use SwitchPreferenceCompat instead.

        android:summary="Lorem ipsum dolor sit amet"
        android:title="Lorem ipsum" />
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.