Search code examples
androidreact-nativeionic-frameworkionic-nativecapacitor

Google Play Games Services in Ionic React (Capacitor)


I'm writing a game in Ionic React - which forces the use of Capacitor.

There is no real Capacitor plugin. Normally in Capacitor, you could use Cordova plugins with the appropriate wrapper, as documented here. So I installed as instructed here, but now Android Studio throws up a bunch of build errors like those:

...\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 suggested use of the package cordova-android-play-services-gradle-release, that didn't solve the issue (as expected, since I'm not using Cordova).


Solution

  • Use this plugin.

    You can install it with npm i openforge/capacitor-game-services into your capacitor project.

    Follow the instructions on the GitHub page to the end before trying to fix errors plopping up.