2016-04-23 89 views
0

我剛完成我的應用程序並生成已簽名的apk並將apk上傳到Play商店作爲測試Alpha。GoogleApiClient無法連接已簽名的apk在調試時工作

除谷歌遊戲服務外,一切似乎都按預期工作。我看到綠盒子連接到Google Play服務,然後幾秒鐘綠色的微調,但它然後繼續當我運行從Android Studio中我的應用程序失敗,並在下面留言logcat的

ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{3b445e29: [email protected]}, message=null}

它工作正常任何想法?

這裏是我的連接代碼:

mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .addConnectionCallbacks(connectCallback) 
      .addOnConnectionFailedListener(connectFailed) 
      .addApi(Games.API, gamesOptions).addScope(Games.SCOPE_GAMES) 
      .build(); 
mGoogleApiClient.connect(); 
+0

對不起。我遇到了你正在解決的問題,但帖子本身有點模糊。到目前爲止,你已經做了什麼來解決這個問題?你在社區檢查過類似的帖子嗎?你在多個設備上測試過它嗎?您可以提供更多信息,您可以從社區獲得更準確的答案。 –

回答

0

這是因爲當您安裝的第一次應用,你需要在谷歌簽署播放services.You需要實現以下回調方法:

@Override 
     public void onConnectionFailed(ConnectionResult connectionResult) { 
      Log.d(TAG, "onConnectionFailed() called, result: " + connectionResult); 

      if (mResolvingConnectionFailure) { 
      Log.d(TAG, "onConnectionFailed() ignoring connection failure; already resolving."); 
      return; 
      } 

      if (mSignInClicked || mAutoStartSignInFlow) { 
      mAutoStartSignInFlow = false; 
      mSignInClicked = false; 
      mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this, mGoogleApiClient, 
       connectionResult, RC_SIGN_IN, getString(R.string.signin_other_error)); 
      } 

      switchToScreen(R.id.screen_sign_in); 
     } 

@Override 
    public void onActivityResult(int requestCode, int responseCode, 
      Intent intent) { 
     super.onActivityResult(requestCode, responseCode, intent); 

     switch (requestCode) { 
      case RC_SIGN_IN: 
       Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode=" 
        + responseCode + ", intent=" + intent); 
       mSignInClicked = false; 
       mResolvingConnectionFailure = false; 
       if (responseCode == RESULT_OK) { 
        mGoogleApiClient.connect(); 
       } else { 
        BaseGameUtils.showActivityResultError(this,requestCode,responseCode, R.string.signin_other_error); 
       } 
       break; 
     } 
     super.onActivityResult(requestCode, responseCode, intent); 
    } 

您可以參考示例項目,以及,https://github.com/playgameservices/android-basic-samples

+0

對不起,我遲到了,但我已經在我的代碼中有這些回調。 – Maantje

+0

你的項目中是否有BaseGameUtils類?它應該調用resolveConnectionFailure並要求登錄Google Play服務。可以在onActivityResult中添加一些日誌檢查。我很確定它也不會調用RC_SIGN_IN。 –