Q:

Из-за чего вылетает Switch? 

<? xml version="1.0" encoding="utf-8"? >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <android.support.v7.widget. SwitchCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/switch1"
        android:text="@string/activity2_Switch"
        android:padding="10dp"
        android:textSize="25sp"
        android:thumb="@drawable/sw_thumb"/>

</LinearLayout>

//
package name;
    import android.content. DialogInterface;
    import android.content. Intent;
    import android.content.pm. ActivityInfo;
    import android.os. CountDownTimer;
    import android.os. SystemClock;
    import android.os. Vibrator;
    import android.support.v7.app. AlertDialog;
    import android.support.v7.app. AppCompatActivity;
    import android.os. Bundle;
    import android.support.v7.app. AppCompatDelegate;
    import android.view. View;
    import android.widget. CompoundButton;
    import android.widget. Switch;
    import android.widget. TextView;

    public class Main2Activity extends AppCompatActivity {
        private Switch myswitch;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate. MODE_NIGHT_YES) {
                setTheme(R.style. Home_Dark);
            } else setTheme(R.style. AppTheme);
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main2);
            myswitch = (Switch) findViewById(R.id.switch1);
            if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate. MODE_NIGHT_YES) {
                myswitch.setChecked(true);
            }
            myswitch.setOnCheckedChangeListener(new CompoundButton. OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) {
                        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate. MODE_NIGHT_YES);
                        recreate();

                    } else {
                        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate. MODE_NIGHT_NO);
                        recreate();
                    }
                }

            });
        }
    }

//
sw_thumb
  <? xml version="1.0" encoding="utf-8"? >
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_checked="true" >
        <shape android:shape="rectangle">
            <solid android:color="#FFF"/>
            <size android:width="35dp" android:height="35dp"/>
            <corners android:radius="50dp"/>
            <stroke android:width="4dp" android:color="@color/colorPrimary"/>
        </shape>
    </item>

    <item android:state_checked="false" >
        <shape android:shape="rectangle">
            <solid android:color="#FFF"/>
            <size android:width="35dp" android:height="35dp"/>
            <corners android:radius="50dp"/>
            <stroke android:width="4dp" android:color="#cdcdcd"/>
        </shape>
    </item>

</selector>

самое главное если заменить одну строчку
(<android.support.v7.widget. SwitchCompat)
 поставить вместо неё  <Switch

<Switch
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/switch1"
        android:text="@string/activity2_Switch"
        android:padding="10dp"
        android:textSize="25sp"
        android:thumb="@drawable/sw_thumb"/>

Всё будет работать , но мне нужно именно как в первом варианте
Код ошибки 
06-11 12:28:33.613 3033-3033/dima113xxx.coin_calculator E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang. RuntimeException: Unable to start activity ComponentInfo{dima113xxx.coin_calculator/dima113xxx.coin_calculator. Main2Activity}: java.lang. ClassCastException: android.support.v7.widget. SwitchCompat cannot be cast to android.widget. Switch
        at android.app. ActivityThread.performLaunchActivity(ActivityThread.java:2059)
        at android.app. ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app. ActivityThread.access$600(ActivityThread.java:130)
        at android.app. ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os. Handler.dispatchMessage(Handler.java:99)
        at android.os. Looper.loop(Looper.java:137)
        at android.app. ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect. Method.invokeNative(Native Method)
        at java.lang.reflect. Method.invoke(Method.java:511)
        at com.android.internal.os. ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os. ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system. NativeStart.main(Native Method)
     Caused by: java.lang. ClassCastException: android.support.v7.widget. SwitchCompat cannot be cast to android.widget. Switch
        at dima113xxx.coin_calculator. Main2Activity.onCreate(Main2Activity.java:32)
        at android.app. Activity.performCreate(Activity.java:5008)
        at android.app. Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app. ActivityThread.performLaunchActivity(ActivityThread.java:2023)
        at android.app. ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
        at android.app. ActivityThread.access$600(ActivityThread.java:130) 
        at android.app. ActivityThread$H.handleMessage(ActivityThread.java:1195) 
        at android.os. Handler.dispatchMessage(Handler.java:99) 
        at android.os. Looper.loop(Looper.java:137) 
        at android.app. ActivityThread.main(ActivityThread.java:4745) 
        at java.lang.reflect. Method.invokeNative(Native Method) 
        at java.lang.reflect. Method.invoke(Method.java:511) 
        at com.android.internal.os. ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
        at com.android.internal.os. ZygoteInit.main(ZygoteInit.java:553) 
        at dalvik.system. NativeStart.main(Native Method) 
06-11 12:28:33.643 3033-3037/dima113xxx.coin_calculator D/dalvikvm: GC_CONCURRENT freed 234K, 3% free 15613K/16007K, paused 12ms+2ms, total 27ms

A:

В ошибке сказано, что SwitchCompat нельзя скаcтовать к Switch:

java.lang. ClassCastException:android.support.v7.widget. SwitchCompat cannot be cast to android.widget. Switch

Вам нужно при определении переменной 
private Switch myswitch;

указать в качестве типа не Switch, а SwitchCompat (с соответствующим импортом этого класса из библиотеки поддержки):
private SwitchCompat myswitch;

