【问题标题】:Toast : Internal Error Occur with integration of Google Plus in AndroidToast:在 Android 中集成 Google Plus 时发生内部错误
【发布时间】:2014-01-26 08:46:29
【问题描述】:

我正在将 Google Plus 集成到我的 Android 应用中。我已经在 Google API 控制台中创建了该项目。我创建了 OAuth 客户端 ID,并仔细检查了包名称和密钥库 SHA1,但两者都是正确的,但我仍然得到 Internal Error Occur

我看过很多帖子,但大多是说与 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 xyz@gmail.com 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: com.android.internal.view.IInputMethodClient$Stub$Proxy@4076b580
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 xyz@gmail.com 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: com.android.internal.view.IInputMethodClient$Stub$Proxy@40605c00
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

【问题讨论】:

标签: android google-plus


【解决方案1】:

我遇到了同样的问题,我在开发者控制台中解决了它。

事实证明,您需要为同意屏幕填写有关您项目的必要信息。

解决方案:

选择您的电子邮件并插入您的项目名称。下次启动应用程序时,您将看到正确的同意屏幕,此后一切正常。

【讨论】:

  • 糟糕的谷歌文档
  • 非常感谢伙计...你们是如何获得此类问题的解决方案的?如果你不介意,你能告诉我吗?
  • 啊!那没有记录! 3、2、1、code.google.com/p/android/issues/detail?id=78145中的Bug
  • 如果你已经在你的谷歌开发者控制台中设置了你的 SHA1 指纹(调试或发布)并且你仍然有这个问题,检查你是否使用你的密钥有效地构建,这里是设置密钥的方法在 Android Studio 中:stackoverflow.com/a/17992232/2486332
【解决方案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 xyz@gmail.com oauth2:PLUS_LOGIN

您能否检查您是否已在您的 API 控制台项目中启用了 Google+ API,您是否也可以尝试完全删除 setScopes 行(PLUS_LOGIN 将是默认设置,因此这似乎是测试是否有任何有趣的事情发生的最简单方法)。

我不确定 PLUS_LOGIN 是否在其中是否表示没有发生替换,或者它只是日志记录看起来像那样,但删除该行应该将其从等式中删除。

编辑 - 根据您更新的转储,范围现在看起来不错,但其中存在无效的客户端 ID 错误。确保客户端 ID 中的 sha 1 周围没有任何尾随空格,并且包名称完全匹配。还可以尝试清除 google play 服务中的缓存(从 google 设置应用程序的菜单中清除数据)。

【讨论】:

  • 我已经添加了我现在得到的第二个日志,并在您建议尝试但仍然无法正常工作的问题中添加了该行。希望尽快收到您的来信!
  • 再次回复 - 看起来像是无效的客户端 ID 错误。建议在 api 控制台上清除播放服务缓存并重新检查 packagename 或 sha1 中的空格等。您还可以检查您的 apk 以确保它是您期望的签名密钥。
  • 一切正常:包名正确,sha1 也正确。这些之间没有空格,我尝试清除 Google Play 服务中的缓存,但仍然是同样的问题。希望尽快收到您的来信!
【解决方案3】:

您必须填写“同意屏幕”,如果您不填写“同意屏幕”中的内容,其他任何操作均无效。

【讨论】:

    【解决方案4】:

    就我而言,需要一些时间才能看到同意屏幕。对 api 控制台进行更改后,最好等待 5-10 分钟,然后尝试登录过程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      相关资源
      最近更新 更多