Google 在 Ionic React(电容器)中玩游戏服务

Google Play Games Services in Ionic React (Capacitor)

我正在用 Ionic React 编写游戏 - 它强制使用 Capacitor。

没有真正的 Capacitor 插件。通常在 Capacitor 中,您可以将 Cordova 插件与适当的包装器一起使用,如 here. So I installed as instructed here 所述,但现在 Android Studio 会抛出一堆构建错误,例如:

...\appname\android\capacitor-cordova-android-plugins\src\main\java\com\berriart\cordova\plugins\GameHelper.java:40: error: cannot find symbol
import com.google.android.gms.games.multiplayer.Invitation;
                                               ^
  symbol:   class Invitation
  location: package com.google.android.gms.games.multiplayer

...\appname\android\capacitor-cordova-android-plugins\src\main\java\com\berriart\cordova\plugins\GameHelper.java:43: 

error: package com.google.android.gms.games.request does not exist
import com.google.android.gms.games.request.GameRequest;

This user 建议使用包 cordova-android-play-services-gradle-release,但这并没有解决问题(正如预期的那样,因为我没有使用 Cordova)。

使用this plugin.

您可以使用 npm i openforge/capacitor-game-services 将其安装到您的电容器项目中。

在尝试修复突然出现的错误之前,请按照 GitHub 页面上的说明进行到底。