2017-06-07 24 views
14

मैं अपने एंड्रॉइड गेम के लिए Google गेम्स टर्न आधारित एपीआई का उपयोग करने की कोशिश कर रहा हूं। मेरे GoogleApiClient को जोड़ने के लिए उपयोग किया जाने वाला कोड Google के एपी नमूने या दस्तावेज़ीकरण से आता है।GoogleApiClient साइन इन विफलता

if (signInClicked || autoStartSignInFlow) { 
     autoStartSignInFlow = false; 
     signInClicked = false; 
     resolvingConnectionFailure = true; 

     // Attempt to resolve the connection failure using BaseGameUtils. 
     // The R.string.signin_other_error value should reference a generic 
     // error string in your strings.xml file, such as "There was 
     // an issue with sign-in, please try again later." 
     if (!BaseGameUtils.resolveConnectionFailure(this, 
       apiClient, connectionResult, 
       RC_SIGN_IN, R.string.signin_other_error)) { 
      resolvingConnectionFailure = false; 
     } 
    } 

पहले दृष्टिकोण से ऊपर TBMP कंकाल नमूना से आता है:

onConnectionFailed की मेरी कार्यान्वयन के अंदर मैं दो अलग-अलग दृष्टिकोण की कोशिश की है। इसके परिणामस्वरूप संदेश

साइन इन करने में विफल रहा। कृपया अपना नेटवर्क कनेक्शन जांचें और पुनः प्रयास करें।

और कनेक्शन कभी नहीं बनाया गया है।

if (connectionResult.hasResolution()) { 
     // https://developers.google.com/android/guides/api-client under 'Handle connection 
     // failures'. I don't know if this is solving the problem but it doesn't lead to 
     // 'please check your network connection' message. 
     try { 
      if(LoggerConfig.ON) { 
       Log.e(TAG, "onConnectionFailure, attempting to startResolutionForResult."); 
      } 
      resolvingConnectionFailure = true; 
      connectionResult.startResolutionForResult(this, REQUEST_RESOLVE_ERROR); 
     } catch (IntentSender.SendIntentException e) { 
      // There was an error with the resolution intent. Try again. 
      if(LoggerConfig.ON) { 
       Log.e(TAG, "onConnectionFailure, there was an error with resolution intent"); 
      } 
      apiClient.connect(); 
     } 
    } 
दूसरा दृष्टिकोण यह startResolutionForResult जो onActivityResult को RESULT_SIGN_IN_FAILED गुजरता बुला समाप्त होता है में

। प्रलेखन से

विफल होने पर साइन इन करते समय परिणाम कोड कॉलिंग गतिविधि पर वापस भेजा गया।

खेलों की सेवा में साइन इन करने का प्रयास विफल रहा। उदाहरण के लिए, यह तब हो सकता है जब नेटवर्क flaky है, या उपयोगकर्ता का खाता अक्षम कर दिया गया है, या सहमति प्राप्त नहीं की जा सकी।

यह मुझे तब से पहेली करता है क्योंकि मुझे नमूना में काम करने के लिए प्रवाह में साइन इन करने में कोई समस्या नहीं है। हालांकि, मेरे गेम में साइन इन विफल होने से पहले मुझे Google खाते का चयन करने के लिए कभी भी संकेत नहीं दिया जाता है।

रिकॉर्ड के लिए मैंने https://developers.google.com/games/services/android/troubleshooting पर सभी चरणों का प्रयास किया है और यह अभी भी विफल रहता है।

साइन इन करने के लिए मैं इस त्रुटि को कैसे हल कर सकता हूं?

+3

इसके अलावा अपने लॉग मदद कर सकता है की जाँच करें भी – MohammedAlSafwan

+0

आप की कोशिश की है https://stackoverflow.com/questions/26804929/failed-to-sign- कृपया-कृपया-जांच-अपने-नेटवर्क-कनेक्शन-और-कोशिश-पुनः? rq = 1? और क्या आप एक [एमसीवीई] पोस्ट कर सकते हैं (https://stackoverflow.com/help/mcve)? –

उत्तर

0

प्रयास करें onStart() विधि में private GoogleApiClient mGoogleApiClient;

mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) 
       .addApi(LocationServices.API) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .build(); 

कॉल mGoogleApiClient.connect();

@Override 
    public void onStart() { 
     super.onStart(); 
     mGoogleApiClient.connect(); 
    } 
+0

उपर्युक्त प्रश्न Google गेम्स एपीआई के लिए स्थान श्रोता नहीं है ...! –

2
private GoogleApiClient mGoogleApiClient; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    // Create the Google Api Client with access to the Play Games services 
    mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .addConnectionCallbacks(this) 
      .addOnConnectionFailedListener(this) 
      .addApi(Games.API).addScope(Games.SCOPE_GAMES) 
      // add other APIs and scopes here as needed 
      .build(); 

    // ... 
} 

@Override 
protected void onStart() { 
    super.onStart(); 
    mGoogleApiClient.connect(); 
} 

@Override 
protected void onStop() { 
    super.onStop(); 
    mGoogleApiClient.disconnect(); 
} 

आगे के संदर्भ के लिए, लिंक link

संबंधित मुद्दे