From The Blog: New Google Play Games Services plugin

Corona Labs is pleased to announce the immediate availability of a new, updated Google Play Games Services plugin. This plugin in a complete rewrite of the version one of the plugin using the latest GPGS core libraries and dependencies.

One of the key reasons for the GPGS v2 plugin, besides staying with modern underlying SDK’s is support for preventing Google rejections for using invalid login scopes. The previous version of the underlying GPGS SDK contained Google Plus login scope which has been deprecated. The new version has this removed.

The GPGS v2 plugin should be a drop in replacement for the GPGS v1 plugin. First, visit the Marketplace and activate the plugin, then simply update your build.settings to include the plugin using:

settings = { plugins = { ["plugin.gpgs.v2"] = { publisherId = "com.coronalabs", supportedPlatforms = { ["android"] = true, } } } }

And where you require the plugin in your lua code:

local gpgs = require( "plugin.gpgs.v2" )

This is a completely new version of the plugin and you should fully test your app against the code. If you have questions about the new plugin, please check out our documentation. Join us in the community forums to discuss this new plugin.

View the full article

Anyone else having problems adapting to the new plugin? I followed the documentation and can’t make it work.

Indeed I had received one mysterious bug report about gpgs and login from the previous version.

Regards

Can you be more specific about what’s not working? Errors? the version of Corona you’re using? Any messages from your device’s console (adb logcat)?

Rob

I could receive the “logged in” event with no errors and the gpgs welcome message is showing.

gpgs.isConnected() is returning false, though.

When calling gpgs.isConnected()

10-07 16:12:21.935 3674 8087 W AppOps : Bad call: specified package com.google.android.gms under uid 10698 but it is really 10020 10-07 16:12:21.935 3674 8087 W AppOps : java.lang.RuntimeException: here 10-07 16:12:21.935 3674 8087 W AppOps : at com.android.server.AppOpsService.getOpsRawLocked(AppOpsService.java:1402) 10-07 16:12:21.935 3674 8087 W AppOps : at com.android.server.AppOpsService.checkPackage(AppOpsService.java:1106) 10-07 16:12:21.935 3674 8087 W AppOps : at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:169) 10-07 16:12:21.935 3674 8087 W AppOps : at android.os.Binder.execTransact(Binder.java:682) 10-07 16:12:21.954 4244 4632 W GamesServiceBroker: Client connected with SDK 12451000, Services 14366021, and Games 70890048 10-07 16:12:21.956 4244 4735 W GamesServiceBroker: Client connected with SDK 14366000, Services 14366021, and Games 70890048 10-07 16:12:21.961 3674 8087 W AppOps : Bad call: specified package com.google.android.gms under uid 10698 but it is really 10020 10-07 16:12:21.961 3674 8087 W AppOps : java.lang.RuntimeException: here 10-07 16:12:21.961 3674 8087 W AppOps : at com.android.server.AppOpsService.getOpsRawLocked(AppOpsService.java:1402) 10-07 16:12:21.961 3674 8087 W AppOps : at com.android.server.AppOpsService.checkPackage(AppOpsService.java:1106) 10-07 16:12:21.961 3674 8087 W AppOps : at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:169) 10-07 16:12:21.961 3674 8087 W AppOps : at android.os.Binder.execTransact(Binder.java:682) 10-07 16:12:21.974 3674 5834 D ConnectivityService: filterNetworkStateForUid() uid: 10020 networkInfo: [type: WIFI[] - WIFI, state: CONNECTED/CONNECTED, reason: (unspecified), extra: "MGNET-PLUG", failover: false, available: true, roaming: false, metered: false] 10-07 16:12:22.021 4210 13502 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed 10-07 16:12:22.021 4210 13502 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.021 4210 13502 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.029 4244 5109 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed 10-07 16:12:22.030 4244 5109 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.030 4244 5109 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.046 4244 5115 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed 10-07 16:12:22.046 4244 5115 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.046 4244 5115 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.075 4210 11241 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed 10-07 16:12:22.075 4210 11241 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.075 4210 11241 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@14366021@14.3.66 (040408-213742215):2) 10-07 16:12:22.517 4244 11707 W GamesServiceBroker: Client connected with SDK 14536000, Services 14366021, and Games 70890048 10-07 16:12:22.529 4244 11711 W GamesServiceBroker: Client connected with SDK 14536000, Services 14366021, and Games 70890048

When calling gpgs.leaderboards.show() directly it confirms it is not connected:

10-07 16:20:08.830 13491 13541 W plugin.gpgs.v2: Not connected

I’m using Corona version 2018.3393

Thanks

Do we require this plugin for the Admob plugin to also work in Google Play apps? I thought we had needed both plugins in order for Admob ads to work in Play Store apps…

The new plugin does not work for me as well.

Tested with latest Public Release als well als latest Daily Build.

Just like lmgualandi I receive the “logged in” event.phase for the “login” event.

However, showing leaderboards and achievements does not work - e.g. “gpgs2.leaderboards.show ()” does nothing, even the listener does not get called.

Edit: When calling gpgs2.leaderboards.show () the Console output is:

W/plugin.gpgs.v2: Not connected

Best regards!

Can you compare your code to:

http://docs.coronalabs.com/tutorial/games/gameLeaderboards/index.html

and see if your login process is different?

If it’s not working can you make a sample app with your code that’s not working?

Rob

I made a sample, but removed my keys. I tested and it works with the old gpgs version.

With the new version, isConnected() is always returning false

https://www.dropbox.com/sh/rww63mjbis9nugk/AAABeg0cV0pPdi9BFsheCWxia?dl=0

I haven’t been using the .isConnected() method in my game/test app. I just added it and I get “true”. Here is my login code:

local function gpgsLoginListener( event ) print("\*\*\* gpgsLoginListener \*\*\*") print( json.prettify( event ) ) if not event.isError then if ( event.name == "login" ) then -- Successful login event myData.isGameNetworkingLoggedIn = true print("I think isConnected() is", gpgs.isConnected()) if myData.gameNetworkingCallback then myData.gameNetworkingCallback() end end end end local function gpgsInitListener( event ) print("\*\*\* gpgsInitListener \*\*\*") print( json.prettify( event ) ) if not event.isError then if ( event.name == "init" ) then -- Initialization event print("\*\*\* Attempting to log in the user to GPGS \*\*\*") gpgs.login( { userInitiated=true, listener=gpgsLoginListener } ) elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) myData.isGameNetworkingLoggedIn = true if myData.gameNetworkingCallback then myData.gameNetworkingCallback() end end end end if gpgs then print("Initializing GPGS") gpgs.init( gpgsInitListener ) end

myData is my global data table but shouldn’t be important in having this work. 

Rob

Ok, but showing the leaderboards isn’t working as well, stating that there’s no connection

They are working for me. Can you tell me more about how you’re testing?  Debug keystore or Release keystore? Are you seeing the game login to GPGS (little banner pops up)?

Are you getting errors in your console log?

How are you looking at the console log?

What device are you testing to?

Rob

  • I’m using a release keystore
  • The exact same code is working when using V1 GPGS Plugin
  • Tested on devices running Android 8.0.0 and 4.2.2 (same behavior)
  • The login banner pops up
  • I’m receiving the “logged in” event, so login seems to work
  • Showing leaderboard or achievements does not work
  • Console output (in Android Studio Logcat) when trying to show leaderboard or achievements is:
    W/plugin.gpgs.v2: Not connected
    Otherwise, no “interesting” console output

I’m pretty much using the code from this tutorial: http://docs.coronalabs.com/tutorial/games/gameLeaderboards/index.html

There are of course endless ways that you can implement things like GPGS. I don’t use the .isConnected() API for instance. We can’t test every possible combination of what you can do. All I can say is that in the game I’m building, it works. Leaderboards show. .isConnected() prints “true”. In fact here is a video that I captured this morning 

https://drive.google.com/file/d/1-3ZU8NL-hAKBOAodHEYb7seQfLv7XHEh/view?usp=sharing

using this code:

local function gameNetworkingLeaderboards() print("\*\*\* gameNetworking leaderboards \*\*\*") if gameNetwork then print("\*\*\* gameNetwork: attempting to call show leaderboard") gameNetwork.show( "leaderboards", { leaderboard = { category = "com.omnigeekmedia.alieninvasion.leaderboard" }, listener = showLeaders }) elseif gpgs then print("\*\*\* GPGS trying to show GPGS leaderboard", myData.gpgs.isConnected()) gpgs.leaderboards.show( ) end end

This is the same code that was working with v1 and it’s working with v2. You need to compare what you’re doing with this and see where you’re different. I’m not saying that we don’t have a bug, it’s very possible, but we need to know what’s different between how you’re trying to use it and how we are. 

I ran your test app and here is the console log from the run:

Oct 10 10:52:13.808 ---------- Device Log Starts ---------- Oct 10 10:52:14.926 Nexus 9: Platf Oct 10 10:52:14.926 orm: Nexus 9 / ARM Neon / 7.1.1 / NVIDIA Tegra / OpenGL ES 3.1 NVIDIA 343.00 / 2018.3401 / English | US | en\_US | en Oct 10 10:52:14.971 Nexus 9: Unable Oct 10 10:52:14.971 to start service Intent { cmp=com.omnigeekmedia.Alien\_Invasion/shared.google.play.services.base.PackageStateChangedService } U=0: not found Oct 10 10:55:06.396 Nexus 9: App starting Oct 10 10:55:06.397 Nexus 9: WARNIN Oct 10 10:55:06.397 G: licensing.init() was already called for google. Nexus 9: licensingInit == true Oct 10 10:55:07.284 Nexus 9: \>\> Oct 10 10:55:07.284 Nexus 9: { Nexus 9: "name":"init", Nexus 9: "type":"init", Nexus 9: "isError":false Nexus 9: } Oct 10 10:55:08.224 Nexus 9: \>\> Oct 10 10:55:08.237 Nexus 9: { Nexus 9: Oct 10 10:55:08.238 "name":"login", Nexus 9: "phase":"logged in", Nexus 9: "isError":false Nexus 9: } Oct 10 10:55:11.061 Nexus 9: Attempting new login Oct 10 10:55:11.078 Nexus 9: \>\> Ne Oct 10 10:55:11.078 xus 9: { Nexus 9: "name":"login", Nexus 9: "phase":"logged in", Nexus 9: "isError":false Nexus 9: } Oct 10 10:55:21.718 Nexus 9: Is Oct 10 10:55:21.718 connected true

The only difference was using my Package Name, my googlePlayGamesAppId in build.settings, and my “key” in config.lua

It’s possible you don’t have something configured correctly on Google Play that the V2 plugin depends on that the V1 did not.

Rob

My behavior is just like bjoern, except I’m using adb logcat.

I’m reviewing my configurations on the console, but still no luck

Sorry, quoting myself here :-)  But does anyone know the answer to my question above?  I’m hoping I only need to do the change for the apps that have leaderboards, and not all of my apps.

No, GPGS is used for game activities like leaderboards and achievements, multi-player game support, saving game data across devices, etc.  AdMob does not need this in any way.

Rob

I’m checking everything on Google Play, but I could not find a problem so far.

I’m wondering if there is an issue with how Corona handles the resource files for leaderboards/achievements? How is this done?

In a native app you would just create an res/values/games-ids.xml file with the content generated by Google Play Games Console.

Best regards!

@bjoern, what is the status on your app with regards to alpha test, beta test, release? Is your account an authorized tester? Here is what the engineer had to say:

“I looked at this issue and here are my thoughts. When I started working on this plugin I also got every time isConnected() false in any case until I put the app signed with the correct key into Google Play Console, particularly, into internal test branch of release section. After that, I added my own email addresses into testers list, activated Play Game Services for this app and only then became able to download it from play store. Until I done all of these isConnected() returned false every time. When I installed the test app from Google Play store, everything behaved as expected and isConnected() has returned true.”

My app is set up as an Alpha test with my email as a tester. Maybe something in what he said will give you a clue as to the difference.

Rob

I just tested it the way described above - I uploaded my APK signed with the release key as internal test to Google Play Console, and also made it available for Alpha test. My account is registered as tester for internal tests and for Alpha tests. I installed the Alpha test version of the app on the device from Google Play Store. (My leaderboard and achievements are all in a published state).

I still get the same behavior as described above.

Hi Rob,

I’ve just did the same test here with my game and got the same results. I’ve created an internal test track on Google Play and uploaded the game. After downloading it through my test user I confirm that leaderboards and achievements are not working for me neither.