title: Getting "Already managing a GoogleApiClient with id 0" exception when using TabLayout Viewpager
body: <p>I want to integrate Google Signup using TabLayout ViewPager Fragments. ViewPager contains two fragments LoginFragment and RegistrationFragment and both contains "Google Signup" button.</p>
  
  <p>Problem is that I'm getting following error when launch activity.</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Already managing a GoogleApiClient
    with id 0</p>
  </blockquote>
  
  <p>Complete error log-</p>
  
  <pre><code>java.lang.IllegalStateException: Already managing a GoogleApiClient with id 0
  at com.google.android.gms.common.internal.zzac.zza(Unknown Source)
  at com.google.android.gms.internal.zzzt.zza(Unknown Source)
  at com.google.android.gms.common.api.GoogleApiClient$Builder.zzf(Unknown Source)
  at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
  at com.naturesouq_shopping.fragment.RegistrationFragment.buildGoogleApiClient(RegistrationFragment.java:174)
  at com.naturesouq_shopping.fragment.RegistrationFragment.getIds(RegistrationFragment.java:140)
  at com.naturesouq_shopping.fragment.RegistrationFragment.onCreateView(RegistrationFragment.java:85)
  at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
  at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
  at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
  at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
  at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
  at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
  at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
  at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
  at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
  at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
  at android.view.View.measure(View.java:20236)
  </code></pre>
  
  <p>I'm trying following code</p>
  
  <pre><code>  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
   // Configure sign-in to request the user's ID, email address, and basic
   // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
          gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestEmail()
                  .build();
  
          buildGoogleApiClient();
  
       // .....
   }
  
  private synchronized void buildGoogleApiClient() {
      /** build_client */
     try {
         mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                 .enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */)
                 .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                 .build();
     } catch (Exception e) {
         e.printStackTrace();
     }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Override
  public void onStart() {
      super.onStart();
      if (mGoogleApiClient != null) {
          mGoogleApiClient.connect();
      } 
  
  }
  
  @Override
  public void onStop() {
      Log.d("GARG", "***** on Stop ***** ");
      if (mGoogleApiClient != null &amp;&amp; mGoogleApiClient.isConnected()) {
          Log.d("GARG", "***** on Stop mGoogleApiClient disconnect ***** ");
  
          mGoogleApiClient.stopAutoManage(getActivity());
          mGoogleApiClient.disconnect();
      }
      super.onStop();
  }
  </code></pre>
  
  <p>Is there another way to connect Google API client?
  Any idea on where i am doing wrong and the correct way ?</p>