Unable to start activity ComponentInfo... java.lang.NullPointerException
<p>My application was running perfect then suddenly error appear and i dont know what to do.. i apply different solution but nothing help.. i am making view pager with fragment and when i add button in my fragment then this error come after this i remove the button but error is not going..</p>

<p>slider_activity class</p>

<pre><code>public class Slider_activity extends FragmentActivity {

    ViewPager viewPager = null;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.slider_activity);
         setPager(); /// line 26
    }

    private void setPager(){
        viewPager = (ViewPager) findViewById(R.id.pager);
        FragmentManager fragmentManager = getSupportFragmentManager();
        viewPager.setAdapter(new MyAdapter(fragmentManager));

    }
}
</code></pre>

<p>slider_activity.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

&lt;/android.support.v4.view.ViewPager&gt;
</code></pre>

<p>error</p>

<pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.amir.namaztimer/com.example.amir.namaztimer.Slider_activity}: java.lang.NullPointerException
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                                                                               at android.app.ActivityThread.access$600(ActivityThread.java:141)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:137)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5041)
                                                                               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:793)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                                                                               at dalvik.system.NativeStart.main(Native Method)
                                                                            Caused by: java.lang.NullPointerException
                                                                               at com.example.amir.namaztimer.Slider_activity.onCreate(Slider_activity.java:26)
                                                                               at android.app.Activity.performCreate(Activity.java:5104)
                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
                                                                               at android.app.ActivityThread.access$600(ActivityThread.java:141) 
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                               at android.os.Looper.loop(Looper.java:137) 
                                                                               at android.app.ActivityThread.main(ActivityThread.java:5041) 
                                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
</code></pre>