Android ndk Google Play游戏服务集成失败;Play Games回调表示连接失败。”;

Android ndk Google Play游戏服务集成失败;Play Games回调表示连接失败。”;,android-ndk,google-play-services,google-play-games,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

我已经使用极简主义代码示例将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开发者控制台中创建了一个游戏服务,并链接了两个应用程序
  • 带有调试键的链接应用程序
  • 具有释放密钥的链接器应用程序
  • 从链接的应用程序中获取应用程序id(两个链接的应用程序的id相同),并将其放入res/values/ids.xml中
  • 创建排行榜,并将其ID放入res/values/game-IDs.xml中
  • 在my AndroidManifest.xml中添加了带有name=“com.google.android.gms.games.APP_ID”和value=“@string/APP_ID”的标记
  • 已下载游戏服务应用程序的最新更新
  • 将自己列为测试用户
我不确定哪条消息是原始错误,哪条是症状。 “连接失败”或“需要UI交互”

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

我使用的源代码是C++代码示例中的StaseMaGeAg..cp的逐字复制,并且在我的ANDROIDIMAN中我也复制了示例代码片段:

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

因此,事实证明,这种行为的目的是: 如果您以前从未登录过,自动登录(服务启动时)将失败

您需要首先使用以下方式进行用户启动的登录:

game_services_->StartAuthorizationUI();
…在后续自动登录成功之前

还要注意的是,控制台上有很多错误,这些错误似乎不会干扰GooglePlay游戏服务的正常运行

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 console中缺少链接的应用程序,也可能出现“结果-3”。您需要两个链接的应用程序:一个带有调试键,另一个带有发布键。我应该何时执行StartAuthorizationUI()?当AuthFinished回调被执行并返回时-3?@ViktorSehr当用户点击Google登录按钮时,我调用它。