Google Play游戏服务集成失败,“Play游戏回调表示连接失败”。

时间:2014-12-01 22:04:37

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

我已使用极简主义代码示例将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开发者控制台中创建了一个游戏服务,并链接了两个应用。
  • 使用调试键链接应用
  • 带有发布密钥的链接器应用
  • 从链接的应用中获取app-id(两个链接应用的ID相同)并将其放入res / values / ids.xml
  • 创建排行榜,并将其ID放在res / values / game-ids.xml
  • 为我的AndroidManifest.xml添加了标签,名称为" com.google.android.gms.games.APP_ID"和value =" @ string / app_id"
  • 下载最新的游戏服务应用更新。
  • 将自己列为测试用户。

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

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

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

// 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);
}

1 个答案:

答案 0 :(得分:6)

因此,事实证明此行为是: 如果您之前从未登录过,则自动登录(在服务启动时)应该会失败。

您需要先执行用户启动的登录,然后执行以下操作:

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

最后一点:奇怪的是,我也看到了用户互动所需要的'尝试在没有网络连接的情况下登录时出错。