我的应用程序没有客户端 ID?

My App has no Client ID?

所以我正在使用 Unreal Engine 4 制作手机游戏。我目前正在尝试设置 Google Play 服务,以便我可以进行排行榜、成就和应用内购买,但我现在正在努力解决第一个问题。

您可以在此 short video 中看到行为。

它似乎试图联系该服务,然后出了点问题,它放弃了。发生这种情况时,我从 phone 中创建了一个 logcat 日志文件,这就是我得到的:

I/GamesNativeSDK(16078): Connecting to Google Play...

V/GamesNativeSDK(16078): Attached to JVM on thread main_dispatch

D/ChimeraCfgMgr(11916): Loading module com.google.android.gms.games from APK com.google.android.play.games

D/ChimeraModuleLdr(11916): Module APK com.google.android.play.games already loaded

D/ChimeraCfgMgr(11916): Loading module com.google.android.gms.games from APK com.google.android.play.games

D/ChimeraModuleLdr(11916): Module APK com.google.android.play.games already loaded

V/GamesNativeSDK(16078): Play Games callback indicates connection failure.

I/GamesNativeSDK(16078): UI interaction required to connect to Google Play.

D/UE4     (16078): [2015.10.26-19.31.29:804][  0]LogOnline:Warning: Async task 'Login' failed in 0.582350 seconds

E/SignInIntentService(11916): Access Not Configured. The API (Google Play Game Services API) is not enabled for your project. Please use the Google Developers Console to update your configuration.

E/SignInIntentService(11916): com.google.android.gms.games.server.error.GamesException

E/SignInIntentService(11916):  at com.google.android.gms.games.server.GamesServer.getResponseBlocking(GamesServer.java:164)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.PlayerAgent.getPlayerFromNetwork(PlayerAgent.java:1700)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.PlayerAgent.fetchPlayer(PlayerAgent.java:621)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.DataBroker.loadSelf(DataBroker.java:920)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$LoadSelfOperation.executeInternal(PlayGamesSignInIntentService.java:402)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$BaseOperation.execute(PlayGamesSignInIntentService.java:51)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$OperationAdapter.execute(PlayGamesSignInIntentService.java:487)

E/SignInIntentService(11916):  at com.google.android.gms.chimera.BaseAsyncOperationService$OperationTask.run(BaseAsyncOperationService.java:179)

E/SignInIntentService(11916):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

E/SignInIntentService(11916):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

E/SignInIntentService(11916):  at java.lang.Thread.run(Thread.java:818)

E/LoadSelfFragment(16219): Unable to sign in - application does not have a registered client ID

我理解错误信息,但不明白为什么会收到这些信息。我尝试直接从启动器部署以及制作签名 APK 并安装在我的 phone 上。结果是一样的。

我四处寻找这个问题的解决方案,但我在我的开发者控制台中找不到任何设置问题,也没有发现任何遗漏。我在这里有点不知所措,我的目标是在 2015 年 12 月发布,所以我需要帮助。 Epic Games 几乎没有关于节点的文档来执行此操作,所以所有这些都是我在黑暗中摸索的。

在黑暗中经过多次斗争和摸索之后,我现在自己找到了解决方案。请关注this link到虚幻论坛看看我是怎么做到的!

它的基本要点是:

确保以下 API 在您的开发者控制台中已解锁:

  • Google Android
  • 的云消息传递
  • Google云Pub/Sub
  • Google 云用户帐户
  • Google 玩 Android 开发者 API
  • Google玩游戏管理
  • Google 玩游戏服务
  • Google+ API

确保您的凭据中有 public 服务器密钥,IP 列表中没有 IP。

将以下两行添加到项目设置的<manifest>部分。

  • com.google.android.gms.games.APP_ID="@string/app_id"
  • com.google.android.gms.appstate.APP_ID="@string/app_id"

然后将所有这些权限添加到项目的Extra Permissions部分

  • com.android.vending.BILLING(仅当您有应用内购买时)
  • android.permission.INTERNET
  • android.permission.GET_ACCOUNTS
  • android.permission.USE_CREDENTIALS

打开构建文件夹并在 <PROJECT NAME>\Build\Android\res\values 找到的 GooglePlayAppID.xml 中添加您的应用程序 ID

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_id">YOUR GAMES APP ID HERE</string>
</resources>

现在您应该可以使用 Epic 提供的节点来实现成就、排行榜和应用内购买了。

另一个重要步骤(在 Unreal 论坛 link 中)是对 YourProject.build.cs 的以下补充:

if (Target.Platform == UnrealTargetPlatform.Android)
{
    PrivateDependencyModuleNames.Add("OnlineSubsystem");
    PrivateDependencyModuleNames.Add("OnlineSubsystemGooglePlay");
}

来源:https://forums.unrealengine.com/showthread.php?67343-How-do-I-debug-refusal-to-connecto-to-Google-Play-services

(其他平台可能需要在线子系统,例如 Windows/Steam)