2014-01-26 55 views
8

我正在將Google Plus集成到我的Android應用中。我已經在Google API控制檯中創建了該項目。我創建了OAuth客戶端ID,並且我檢查了包名和Keystore SHA1,但兩者都是正確的,但我仍然獲得Internal Error Occur敬酒:內部錯誤與Google Plus在Android中的集成發生

我見過很多線程,但大多數說與SHA1和包名稱在這裏是正確的有關。

大家分享你的看法。


編輯:我已經使用debug.keystore和自定義創建的密鑰庫進行了測試,但沒有爲我工作。

setScopes("PLUS_LOGIN")對我也沒有幫助。


public class MainActivity extends Activity implements ConnectionCallbacks, 
     OnConnectionFailedListener, OnClickListener { 

    private static final int REQUEST_CODE_RESOLVE_ERR = 9000; 

    private ProgressDialog mConnectionProgressDialog; 
    private PlusClient mPlusClient; 
    private ConnectionResult mConnectionResult; 

    private static final String TAG = "Google Plus Demo"; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mPlusClient = new PlusClient.Builder(this, this, this) 
       .setActions("http://schemas.google.com/AddActivity", 
         "http://schemas.google.com/BuyActivity") 
       .setScopes(Scopes.PLUS_LOGIN).build(); 

     // Progress Bar to be displayed if the connection failure is not 
     // resolved. 
     mConnectionProgressDialog = new ProgressDialog(this); 
     mConnectionProgressDialog.setMessage("Signing in..."); 

     findViewById(R.id.sign_in_button).setOnClickListener(this); 

    } 

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

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

    @Override 
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) { 
     if(requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) { 
      mConnectionResult = null; 
      mPlusClient.connect(); 
     } 
    } 

    @Override 
    public void onConnectionFailed(ConnectionResult result) { 
     if(mConnectionProgressDialog.isShowing()) { 
      // The user clicked on the sign-in button already. Start to resolve 
      // connection errors. Wait until onConnected() to dismiss the 
      // connection dialog. 

      if(result.hasResolution()) { 
       try { 
        result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR); 
       } catch(SendIntentException e) { 
        mPlusClient.connect(); 
       } 
      } 
     } 

     // Save the result 
     mConnectionResult = result; 
    } 

    @Override 
    public void onConnected(Bundle connectionHint) { 
     String accountName = mPlusClient.getAccountName(); 
     Toast.makeText(this, accountName, Toast.LENGTH_LONG).show(); 
     mConnectionProgressDialog.dismiss(); 
    } 

    @Override 
    public void onDisconnected() { 
     Log.d(TAG, "Disconnected"); 
    } 

    @Override 
    public void onClick(View view) { 
     if(view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) { 
      if(mConnectionResult == null) { 
       mConnectionProgressDialog.show(); 
      } else { 
       try { 
        mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR); 
       } catch(SendIntentException e) { 
        // Try connecting again 
        mConnectionResult = null; 
        mPlusClient.connect(); 
       } 
      } 
     } 
    } 
} 

日誌

01-27 20:22:23.871: I/GLSUser(1699): GLS error: INVALID_SCOPE [email protected] oauth2:PLUS_LOGIN 
01-27 20:22:23.871: W/GLSActivity(1699): [aia] Status from wire: INVALID_SCOPE status: INVALID_SCOPE 
01-27 20:22:23.965: W/InputManagerService(1536): Window already focused, ignoring focus gain of: [email protected] 
01-27 20:22:24.020: I/eFrame(3180): pkgname_before:com.google.android.gms class:com.xicom.appdemo.MainActivity 
01-27 20:22:24.027: D/SurfaceFlinger(1536): Layer[34bee8]:: Tile format buffer w[256] h[64] f[1] v[0x47855000] p[0x97fd5000] sz[65536] 
01-27 20:22:25.012: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0 
01-27 20:22:25.012: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause 
01-27 20:22:25.106: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep 
01-27 20:22:27.684: W/PowerManagerService(1536): Timer 0x3->0x3|0x3 
01-27 20:22:27.691: D/BatteryService(1536): update start 

代碼:

mPlusClient = new PlusClient.Builder(this, this, this) 
    .setActions("http://schemas.google.com/AddActivity", 
      "http://schemas.google.com/BuyActivity") 
    .build(); 

登錄第二個版本

01-28 22:25:16.164: D/SurfaceFlinger(1536): Layer[37c9c0]:: Tile format buffer w[256] h[320] f[1] v[0x4ac99000] p[0x94741000] sz[327680] 
01-28 22:25:17.007: D/SurfaceFlinger(1536): Layer[8a5a68] [4] non-RGB565 reloads 
01-28 22:25:17.250: I/fno(2652): I/O exception (javax.net.ssl.SSLException) caught when processing request: Write error: ssl=0x25d728: I/O error during system call, Broken pipe 
01-28 22:25:17.250: I/fno(2652): Retrying request 
01-28 22:25:18.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads 
01-28 22:25:18.101: V/AudioFlinger(1323): Audio hardware entering standby, mixer 0x6f228, mSuspended 0 
01-28 22:25:18.101: D/AudioStreamOutALSA(1323): AudioStreamOutALSA::standby--pause 
01-28 22:25:18.187: D/BatteryService(1536): update start 
01-28 22:25:18.195: V/AudioFlinger(1323): MixerThread 0x6f228 TID 1473 going to sleep 
01-28 22:25:19.015: D/SurfaceFlinger(1536): Layer[8a5a68] [10] non-RGB565 reloads 
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null 
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: INVALID_CLIENT_ID status: null 
01-28 22:25:19.484: I/GLSUser(2652): GLS error: INVALID_CLIENT_ID [email protected] oauth2:https://www.googleapis.com/auth/plus.login 
01-28 22:25:19.484: W/GLSActivity(2652): [aia] Status from wire: Unknown status: UNKNOWN 
01-28 22:25:19.570: D/dalvikvm(20673): GC_EXTERNAL_ALLOC freed 163K, 43% free 3397K/5959K, external 511K/517K, paused 47ms 
01-28 22:25:19.664: W/InputManagerService(1536): Window already focused, ignoring focus gain of: [email protected] 
01-28 22:25:19.781: D/SurfaceFlinger(1536): Layer[278dc0]:: Tile format buffer w[256] h[64] f[1] v[0x49520000] p[0x97fcc000] sz[65536] 
01-28 22:25:19.835: I/eFrame(20257): pkgname_before:com.google.android.gms class:com.xicom.appdemo.MainActivity 
01-28 22:25:20.046: D/dalvikvm(20257): GC_CONCURRENT freed 384K, 49% free 3021K/5895K, external 412K/517K, paused 4ms+6ms 
01-28 22:25:20.757: W/PowerManagerService(1536): Timer 0x3->0x3|0x3 
01-28 22:25:23.203: D/BatteryService(1536): update start 
+0

[「內部錯誤發生」與Google Plus登錄集成的可能重複](http://stackoverflow.com/questions/15762904/an-internal-error-occurred-with-integration-of-google-plus -login) – bummi

+0

我得到了同樣的錯誤。它發生在從谷歌登錄客戶端請求電子郵件時。 – Choxmi

回答

2

你得到任何輸出在logcat去與錯誤?嘗試啓用詳細日誌記錄,如果你還沒有(見https://developers.google.com/+/mobile/android/getting-started#frequently_asked_questions

adb shell setprop log.tag.GooglePlusPlatform VERBOSE 

編輯:謝謝你添加日誌。在GLS錯誤是有趣的有:

I/GLSUser(1699):GLS錯誤:INVALID_SCOPE [email protected]的oauth2:PLUS_LOGIN

你能檢查是否已啓用了Google+ API在API控制檯項目,你也可以嘗試完全刪除setScopes行(PLUS_LOGIN將是默認的,所以這似乎是最簡單的方法來測試是否有什麼有趣的事情發生)。

我不確定我的頭頂是否PLUS_LOGIN在它們的指示替換沒有發生,或者它只是日誌看起來像那樣,但刪除行應該從等式中刪除它。

編輯 - 基於您的更新轉儲範圍現在看起來不錯,但有一個無效的客戶端Id錯誤。確保客戶端Id中sha 1的周圍沒有任何尾隨空格,並且包名稱完全匹配。也請嘗試清除谷歌播放服務中的緩存(清除谷歌設置應用程序菜單中的數據)。

+0

我在我的問題中添加了日誌。請參閱 – android

+0

更新了答案。 –

+0

我的API控制檯項目中已經啓用了Google+ API – android

45

我遇到了同樣的問題,我在開發人員控制檯中解決了這個問題。

原來你需要在同意屏幕上填寫項目的必要信息。

解決方案:

選擇你的電子郵件,並插入您的項目名稱。下次啓動應用程序時,您將獲得適當的同意屏幕,此後所有工作都將正常工作。

+0

非常感謝..這是我想念的! –

+0

wah..bhura wah .. –

+0

該答案應該被接受! – toantran

0

您必須填寫「同意書屏幕」,如果您未填寫「同意書屏幕」中的內容,則沒有其他作品。

+0

這已經在最高的投票答案中提到了。 – bummi

0

就我而言,花了一些時間才能看到同意屏幕。在更改api控制檯之後,最好等待5-10分鐘,然後嘗試登錄過程。