Online multiplayer game using Google Play Games Services in Cocos2D-X

I’ve take it from “samples\sdkbox-sample-gpg” project and haven’t change:

strings.xml :
<resources>
<string name="app_name">GPG_CPP</string>
<string name="google_app_id">777734739048</string>
<string name="service_id">com.sdkbox.hugo.test.gpg.nearby</string>

AndroidManifest.xml :
<manifest ...
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/google_app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.nearby.connection.SERVICE_ID" android:value="@string/service_id" />
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="your_app_id_here" />
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/google_app_id" />

  • I see APP_ID there 3 times. Q1 is it ok?
    Q2 What values should be for app_name , google_app_id , service_id if I want just to test if Cocos works stable with GPG::MTB ?
    Q3 Can I use these from your released sample?
    Q4 If I make a release version, publish it in alpha-mode, turn/plug GPG services for this app, then build a debug and run it from my device - will it work?

Q1 you need to remove the duplicated entries
Q2, Q3 should be okey, you can simply just use the sample
Q4 yes debug build work, you have to follow the setup process very closely. And there are special step you need to perform.

Also we already highlighted in the documentation (you can get more information in the documentation)

Note: Google Play Games Services will use your release keystore by default, if you want to test your game in debug settings, please link an additional app with debug keystore

Q1 So, I have to create debug.keystore and release.keystore on my PC, build debug/release apk with sample data (app_name , google_app_id , service_id), install it on my device and I should be able to connect via it to Google Play as your released com.sdkbox.gpg tester? There will be no apk/keystores conflict?

Q2 console.developers.google.com/apis/credentials/oauthclient offers me some long string client_id and project_id, and offers to save that data as client_secret_xxxxxx.apps.googleusercontent.com.json, and to use that json… Am I get right - it is not necessary for me to use all that data in my build apk to connect to com.sdkbox.gpg Game services?

You can use debug.keystore since all android debug key are the same. You can’t use release.keystore since you don’t have our release.keystore and your key own won’t work.

oauthclient id are required for iOS, please refer to documentation

I’ve update SDKbox to v1.0.0.20 and gpg to v2.3.4.2 and googleplayservices to v2.3.4.2 for my Android (on Win7 console build) project based on samples\sdkbox-sample-gpg. Also I’ve merged Cocos official 3.13.1 release with last (updated) files from github.

I did: creating my own app and adding GP services to it (and adding my account=gmail in both app alpha-testers list and service testers list and activated it). At last the connection starts: but not at app start but at Sign In press: appears two pop-ups: my App name and connecting to then Google Play Games and then cursor twists without stop…

The error I dig in log is: I GamesNativeSDK: UI interaction required to connect to Google Play.: org.cocos2dx.Addition - it’s my TBM project based on samples\sdkbox-sample-gpg.

I wanted to get what happend in old good SDKBOX gpg from GP, but its app crashes.

This error is because you haven’t link your debug key with gpg http://stackoverflow.com/questions/17612928/should-i-use-debug-keystore-with-google-play-game-services-during-development

Thanks, but…
For my released for Google Play project org.cocos2dx.Addition (alpha testing) I’ve created two Client-ID and updated SHA-1 for them: from debug and release keystores.
But when I start apk debug version or installed from Google Play (after it really updated) release version - it shows the same error in log, and can’t pass Google Play Games pop-up. Log:

11-01 04:14:26.680 20083 20108 D NativeCrypto: ssl=0x62ef0c60 SSL_connect:error exit in UNKWN SSLv3 read server session ticket A: org.cocos2dx.Addition
…then it passes:
11-01 04:14:26.662 20083 20108 D NativeCrypto: ssl=0x62ef0c60 SSL_connect:3RSC_A SSLv3 read server certificate A: org.cocos2dx.Addition

11-01 04:14:26.664 20083 20118 D NativeCrypto: ssl=0x62ef0a70 SSL_connect:3WCKEA SSLv3 write client key exchange A: org.cocos2dx.Addition

11-01 04:14:26.680 20083 20108 D NativeCrypto: ssl=0x62ef0c60 SSL_connect:error exit in UNKWN SSLv3 read server session ticket A: org.cocos2dx.Addition 11-01 04:14:26.680 20083 20108 D NativeCrypto: ssl=0x62ef0c60 info_callback ignored: org.cocos2dx.Addition 11-01 04:14:26.680 20083 20108 D NativeCrypto: doing handshake -- ret=-1: org.cocos2dx.Addition 11-01 04:14:26.680 20083 20108 D NativeCrypto: ssl=0x62ef0c60 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0: org.cocos2dx.Addition

11-01 04:14:26.879 20083 20108 D NativeCrypto: ssl=0x62ef0c60 SSL_connect:ok exit in SSLOK SSL negotiation finished successfully: org.cocos2dx.Addition

11-01 04:14:26.967 2887 11228 W GLSActivity: [ClientIdentityHelper] Fraud! Package org.cocos2dx.Addition isn't associated with uid 10882!: com.google.process.gapps 11-01 04:14:26.967 2887 11228 W GLSActivity: drg: Fraud! Package org.cocos2dx.Addition isn't associated with uid 10882!: com.google.process.gapps

11-01 04:14:27.007 3183 3226 E SignInAsyncService: Fraud! Package org.cocos2dx.Addition isn't associated with uid 10882!: com.google.android.gms 11-01 04:14:27.007 3183 3226 E SignInAsyncService: java.lang.SecurityException: Fraud! Package org.cocos2dx.Addition isn't associated with uid 10882!: com.google.android.gms

Any ideas what should I concentrate on?

Never saw this error before, I guess you do the following

  1. make sure your user account is opt-in with alpha testing
  2. search your project and find out where is uid “10882” came from.

Same apk installed and start on another device - have connected to GP (with another account, added as alpha-tester).
But on new device successful connection to GP happend only once - at very first start. On green arrow or Sign In press - Login Failed. Log may be later; very later.
Program data (and cash) clean haven’t help.
Upd: oops, I use old sdkbox_config.json - from the sample; may be that’s a reason.

I worked on multiplayer game using cocos2dx but with our own server written in ROR, you dont need to worry about sdk box, its very easy to use and integrate i used social feature of sdkbox facebook in my game to login logout friend list invite sent and a lot more.It work perfect for me.You should try at least one time might be you learn new things :slight_smile:

At last I’ve connected! :slight_smile:
May be the problem was, what I have not been enabled (any?) API in https://console.developers.google.com/apis/dashboard?project=MyProject

I’ve get it from log, Google+Android nicely pointed me on that:

11-01 23:00:40.146 1672 6754 E ClientConnectionOperation: jpt: Authorization failed: server returned error: Access Not Configured. Drive API has not been used in project 010101010101 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/drive/overview?project=010101010101 then retry.

Q1: Have I missed (to enable) anything else?
Q2: Where can I read about proper mapping of sdkbox_config.json and my (turn-based multiplayer) game?

No sdkbox_config.json option for google play games, since you can control all of them from google play console.

1 Like

I was having similar issues with this, also getting a Not authourizing. No Client and result -3 error. Adding the support-v4 jar to the project fixed it. To add the support jar in eclipse:

  • RIght click the project ex. MyApp.
  • MyApp -> Android Tools -> Add Support Library

Also make sure that if you have linked the project in Google Play Services console that it is the debug version. I was having an issue when I uploaded a Debug version of the APK to GPS and was then building the project using cocos run -p android -m release.

I am successfully integrated GPGS via sdkbox, but i am having one issue in realtime multiplayer game that i my there is two classes inherit by layer and IRealTimeEventListener, in first class i am creating room and match making , player found their match then it goes to second class, in this class both player are communicating via reliable message but the callbacks of IRealTimeEventListener is not invoking of second class second class is also inherit IRealTimeEventListener. Please help me how i can do that.
Thanks

Anyone know why I can receive real time events using the iPhone emulator but when built and run on an Android device the events are ignored.

For example:

OnRoomStatusChanged() works on iPhone emulator but not on Android device.

Any ideas?

Did you setup android app on your google play console?

Yes the application is working fine, rooms being created, peers connected and capable of sending data to each other, the only problem is that the events like OnRoomStatusChanged() are not being called while OnDataReceived() is. No problems on iPhone emulator.

OnP2PDisconnected() is also not being called when the application is run on Android devices. Everything works perfectly on the iPhone emulator.

How did you fixed your error of “Sign in finished with a result of -3”?