I use the following lines to test the differences between gpgs and gpgs.v2:
gpgs = require( "plugin.gpgs" ) -- or gpgs = require( "plugin.gpgs.v2" ) local function loadLocalPlayerCallback(e) end function loginCallbackGpgs(event) gpgs.players.load({listener = loadLocalPlayerCallback}) end gpgs.login({userInitiated = true, listener = loginCallbackGpgs}) -- some time later: local function submitScore() if gpgs.isConnected() then print ("connected") gpgs.leaderboards.submit({leaderboardId = "xyz", score = 123}) end end
While this works in flight mode on Android with gpgs, it throws out an error when using gpgs.v2 when calling submitScore:
java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context android.content.ContextWrapper.getApplicationContext()’ on a null object reference
I spoke with the engineer that built the plugin and he’s looking to see if he can harden the plugin and he’s trying but it’s pretty difficult. He basically said that you shouldn’t be calling submitScore() when in airplane mode. To work with leaderboards, the user needs to be logged in. Perhaps the old version of the plugin threw away data.
@philipp3, I think it’s safe to say that any app doing networking should check if networking is available before using it. You can choose to use the plugin, you can do native builds, and build your own calls to get networking information, or have a test that checks a high response site by opening a socket connection to a known source with a short timeout to check.
The plugin is probably the easiest approach. Just keep in mind that it just tells you if the device is connected via a method or not, it doesn’t check the quality of the network connection, nor does it check the availability of the server you’re trying to connect to.
I get a similar error after the last update. I have used Corona build 3434.
Here is the error:
Runtime Error
java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context com.ansca.corona.CoronaActivity.getApplicationContext()’ on a null object reference
Is there any news about this or has anybody an idea what exactly is causing this? It seems to be connected to the usage of the gpgs v2 version. For some users the error is appearing when the gpgs.init() is called and for some others when some of the other gpgs functions are called.
This error was also appearing in non-flight mode when accessing gpgs features. After testing different approaches I have removed the gpgs features for now, so the game is stable again. I will return to this issue in a few days.
I spoke with the engineer that built the plugin and he’s looking to see if he can harden the plugin and he’s trying but it’s pretty difficult. He basically said that you shouldn’t be calling submitScore() when in airplane mode. To work with leaderboards, the user needs to be logged in. Perhaps the old version of the plugin threw away data.
@philipp3, I think it’s safe to say that any app doing networking should check if networking is available before using it. You can choose to use the plugin, you can do native builds, and build your own calls to get networking information, or have a test that checks a high response site by opening a socket connection to a known source with a short timeout to check.
The plugin is probably the easiest approach. Just keep in mind that it just tells you if the device is connected via a method or not, it doesn’t check the quality of the network connection, nor does it check the availability of the server you’re trying to connect to.
I get a similar error after the last update. I have used Corona build 3434.
Here is the error:
Runtime Error
java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context com.ansca.corona.CoronaActivity.getApplicationContext()’ on a null object reference
Is there any news about this or has anybody an idea what exactly is causing this? It seems to be connected to the usage of the gpgs v2 version. For some users the error is appearing when the gpgs.init() is called and for some others when some of the other gpgs functions are called.
This error was also appearing in non-flight mode when accessing gpgs features. After testing different approaches I have removed the gpgs features for now, so the game is stable again. I will return to this issue in a few days.