【问题标题】:Google Play Game Services integration fails with "Play Games callback indicates connection failure."Google Play 游戏服务集成失败,并显示“Play 游戏回调指示连接失败”。
【发布时间】:2015-01-30 00:54:29
【问题描述】:

我已使用极简代码示例将 Google 游戏服务与我的 NDK 游戏集成。

启动应用程序时,身份验证失败并在日志中显示:

V/GamesNativeSDK( 7212): Play Games callback indicates connection failure.
I/GamesNativeSDK( 7212): UI interaction required to connect to Google Play.
I/TeapotNativeActivity( 7212): Sign in finished with a result of -3
I/biplane ( 7212): OnAuthActionFinished
I/biplane ( 7212): You are not logged in!
I/TeapotNativeActivity( 7212): Fetching all blocking
I/TeapotNativeActivity( 7212): --------------------------------------------------------------
I/TeapotNativeActivity( 7212): Fetching all nonblocking
I/TeapotNativeActivity( 7212): --------------------------------------------------------------
I/TeapotNativeActivity( 7212): Achievement response status: -3

我已执行在线文档中列出的所有步骤,包括:

  • 在 Google Play Developer Console 中创建了一个游戏服务并关联了两个应用。
  • 使用 Debug 键链接的应用
  • 带有 Release 键的链接器应用
  • 从链接的应用程序中获取 app-id(两个链接的应用程序的 id 相同)并将其放入 res/values/ids.xml 中
  • 创建排行榜,并将其 ID 放入 res/values/game-ids.xml
  • 在我的 AndroidManifest.xml 中添加了 name="com.google.android.gms.games.APP_ID" 和 value="@string/app_id" 的标签
  • 已下载游戏服务应用的最新更新。
  • 将自己列为测试用户。

我不确定哪个消息是原始错误,哪个是症状。 “连接失败”或“需要 UI 交互”。

请注意,在开发者控制台中,两个链接的应用被列为“准备发布”。

我使用的源代码是来自 c++ 代码示例的 StateManager.cpp 的逐字副本,在我的 android_main 中我也复制了示例代码 sn-p:

// gpg-cpp:  Here we create the callback on auth operations
auto callback = [&](gpg::AuthOperation op, gpg::AuthStatus status) {
    LOGI("OnAuthActionFinished");
    if (IsSuccess(status)) {
        LOGI("You are logged in!");
    } else {
        LOGI("You are not logged in!");
    }
    //engine.animating = 1;
};

if (state->savedState != NULL)
{
    // We are starting with a previous saved state; restore from it.
    engine.state = *(struct saved_state*)state->savedState;
    LOGI("Restored state");
}
else
{
    LOGI( "No saved state to restore." );
    gpg::AndroidPlatformConfiguration platform_configuration;
    platform_configuration.SetActivity(state->activity->clazz);
    // Now, create the game service (see StateManager.cpp) and pass in callback
    StateManager::InitServices(platform_configuration, NULL, callback);
}

【问题讨论】:

    标签: android-ndk google-play-services google-play-games


    【解决方案1】:

    所以,事实证明这种行为是有意的: 如果您以前从未登录过,自动登录(在服务启动时)应该会失败。

    您需要先进行用户启动登录,使用:

    game_services_->StartAuthorizationUI();
    

    ...在后续自动登录成功之前。

    另外请注意,控制台上有很多错误,似乎不会干扰 google play 游戏服务的正常运行。

    E/GamesNativeSDK(12369): Exception in dalvik/system/DexClassLoader.loadClass: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.NativeSdkEntryPoints" on path: DexPathList[[zip file "/data/data/com.steenriver.Biplane/app_.gpg.classloader/4da25210572e7e07ea67142ded62c42e.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]].
    W/dalvikvm(12369): Unable to resolve superclass of Lcom/google/android/gms/common/api/d; (148)
    W/dalvikvm(12369): Link of class 'Lcom/google/android/gms/common/api/d;' failed
    I/dalvikvm(12369): Could not find method com.google.android.gms.common.api.d.a, referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.gl
    W/dalvikvm(12369): VFY: unable to resolve static method 3084: Lcom/google/android/gms/common/api/d;.a (Landroid/support/v4/app/FragmentActivity;)Lcom/google/android/gms/common/api/d;
    D/dalvikvm(12369): VFY: replacing opcode 0x71 at 0x0002
    W/dalvikvm(12369): VFY: unable to find class referenced in signature (Landroid/support/v4/app/FragmentActivity;)
    E/dalvikvm(12369): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.enableAutoManage
    W/dalvikvm(12369): VFY: unable to resolve check-cast 149 (Landroid/support/v4/app/FragmentActivity;) in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
    D/dalvikvm(12369): VFY: replacing opcode 0x1f at 0x0010
    

    最后一点:奇怪的是,在没有网络连接的情况下尝试登录时,我还看到了“需要用户交互”错误。

    【讨论】:

    • 请注意,如果您在 Google Play 控制台中缺少链接的应用程序,也可能会出现“结果 -3”。您需要两个关联的应用程序:一个带有调试密钥,一个带有发布密钥。
    • 我应该何时执行 StartAuthorizationUI()? AuthFinished 回调何时执行并返回 -3?
    • @ViktorSehr 我在用户点击 Google 登录按钮时调用它。
    猜你喜欢
    • 2014-04-09
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 2017-07-07
    • 2015-06-28
    • 2018-03-13
    相关资源
    最近更新 更多