Google Play Games Services in Ionic React (Capacitor)

Issue

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.

Answered By – traxx2012

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published