I am working on `android studio`. While my device is in `Portrait` mode it works perfect, but when i rotate my screen to `landscape` mode then the app crashes while giving below error

```
java.lang.RuntimeException: Unable to stop activity {com.example.accurat.myapp/com.example.accurat.myapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.common.api.GoogleApiClient.disconnect()' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3845)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3899)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4103)
at android.app.ActivityThread.-wrap15(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5491)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.common.api.GoogleApiClient.disconnect()' on a null object reference
at com.example.accurat.myapp.MainActivity.onStop(MainActivity.java:249)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1301)
at android.app.Activity.performStop(Activity.java:6414)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3840)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3899) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4103) 
at android.app.ActivityThread.-wrap15(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5491) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

```

and it hits at the below code part

```
 protected void onStop() {
    super.onStop();
    mGoogleApiClient.disconnect(); // it hit here

}

```

The below method is called while getting the coordinates.

```
 protected synchronized  void buildGoogleApiClient() {

    mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    if(mGoogleApiClient != null) {
        mGoogleApiClient.connect();
    }
}

```

Any help would be highly appreciated.