Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

gamecircle.SetSignedInListener causes NullPointerException
Started by tonygod Mar 23 2016 10:58 AM

5 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 197 posts
  • Corona SDK

I am getting a NullPointerException when trying to call gamecircle.SetSignedInListener.

I/System.out(14892): SignedInCallbackNum: -1
I/Corona  (14892): ERROR: Runtime error
I/Corona  (14892): java.lang.NullPointerException
I/Corona  (14892): Java Stack Trace:
I/Corona  (14892): 	plugin.gamecircle.LuaLoader.SetSignedInListener(LuaLoader.java:1383)
I/Corona  (14892): 	plugin.gamecircle.LuaLoader$SetSignedInListenerWrapper.invoke(LuaLoader.java:2393)
I/Corona  (14892): 	com.ansca.corona.JavaToNativeShim.nativeResize(Native Method)
I/Corona  (14892): 	com.ansca.corona.JavaToNativeShim.resize(JavaToNativeShim.java:381)
I/Corona  (14892): 	com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onSurfaceChanged(CoronaGLSurfaceView.java:378)
I/Corona  (14892): 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1612)
I/Corona  (14892): 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)
I/Corona  (14892): stack traceback:
I/Corona  (14892): 	[C]: in function 'SetSignedInListener'
I/Corona  (14892): 	?: in function 'listener'
I/Corona  (14892): 	/Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/timer/timer.lua:198: in function 'method'
I/Corona  (14892): 	/Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:234: in function </Users/jenkins/slaveroot/workspace/Templates/label/android/platform/res

Any ideas what would cause  this?

 

Best regards,

Tony



[TOPIC: post.html]
#2

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 542 posts
  • Corona Staff

Can you show how exactly you call this function? Maybe the callback you are trying to give it is nil?



[TOPIC: post.html]
#3

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 197 posts
  • Corona SDK

I reproduced the error by using the Game Center sample app and converting it to use Gamecircle. 

-- Game Center initialization listener function
local function initCallback( result )

    if ( composer.getVariable( "initializedGC" ) == false ) then

        if ( result ) then

            -- Create "Leaderboards" scene button
            local leaderboardsButton = widget.newButton(
            {
                id = "leaderboards",
                label = "Leaderboards",
                shape = "rectangle",
                width = display.actualContentWidth/2,
                height = 36,
                font = sampleUI.appFont,
                fontSize = 16,
                fillColor = { default={ 0.13,0.34,0.48,1 }, over={ 0.13,0.34,0.48,1 } },
                labelColor = { default={ 1,1,1,1 }, over={ 1,1,1,0.8 } },
                onRelease = handleSceneButton
            })
            leaderboardsButton.anchorX = 1
            leaderboardsButton.anchorY = 0
            leaderboardsButton.x = display.contentCenterX
            leaderboardsButton.y = titleBarBottom
            composer.stage:insert( leaderboardsButton )
            composer.setVariable( "leaderboardsButton", leaderboardsButton )

            -- Create "Achievements" scene button
            local achievementsButton = widget.newButton(
            {
                id = "achievements",
                label = "Achievements",
                shape = "rectangle",
                width = display.actualContentWidth/2,
                height = 36,
                font = sampleUI.appFont,
                fontSize = 16,
                fillColor = { default={ 0.13,0.39,0.44,1 }, over={ 0.13,0.39,0.44,1 } },
                labelColor = { default={ 1,1,1,1 }, over={ 1,1,1,0.8 } },
                onRelease = handleSceneButton
            })
            achievementsButton.anchorX = 0
            achievementsButton.anchorY = 0
            achievementsButton.x = display.contentCenterX
            achievementsButton.y = titleBarBottom
            composer.stage:insert( achievementsButton )
            composer.setVariable( "achievementsButton", achievementsButton )

            -- Set initialized flag as true
            composer.setVariable( "initializedGC", true )

            -- Request local player information
--            gameNetwork.request( "loadLocalPlayer", { listener=requestCallback } )
            gamecircle.GetLocalPlayerProfile( PlayerProfileCallback )

            -- Load leaderboard categories
--            gameNetwork.request( "loadLeaderboardCategories", { listener=requestCallback } )
            gamecircle.Leaderboard.GetLeaderboards( LeaderboardCallback )

            -- Load achievement descriptions
--            gameNetwork.request( "loadAchievementDescriptions", { listener=requestCallback } )
            gamecircle.Achievement.GetAchievements( AchievementCallback )

            -- Load player achievements
--            gameNetwork.request( "loadAchievements", { listener=requestCallback } )
        else
            -- Display alert that Game Center cannot be initialized
            native.showAlert( "Error", "Player is not signed into GameCircle", { "OK" } )
        end

        local printTable = composer.getVariable( "printTable" )
        printTable( result )
    end
end


-- Initialize Gamecircle if platform is an Amazon device
if ( system.getInfo( "targetAppStore" ) == "amazon" ) then
    gamecircle.Init( true, true, true )
    gamecircle.SetSignedInListener( initCallback ) -- CRASHES
else
    native.showAlert( "Not Supported", "Amazon GameCircle is not supported on this platform. Please build and deploy to an Amazon device.", { "OK" } )
end


[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Tony,

This plugin was written by a 3rd party. We don't have access to the code, nor can we fix/support it.

 
The best advice we can recommend is to work-around this issue. The stack trace points out where in code this issue is being triggered. That would be the SetSignedInListener(). If you set the "neverStripDebugInfo" build.setting to true, then the stacktrace will reveal the Lua file name and line number to help track it down.
 
 
From there, you can add some Lua print() functions to see if the arguments you're feeding into the plugin are invalid or not.
 
Brent


[TOPIC: post.html]
#5

tonygod

[GLOBAL: userInfoPane.html]
tonygod
  • Contributor

  • 197 posts
  • Corona SDK

I have a workaround that I am using in production now, so I am not asking for a fix at this time.  I think the documentation should reflect the behavior, though.

 

The console output with neverStripDebugInfo is below.  The only thing it clarified was where my call to SetSignedInListener was (main.lua line 364).   The crash is clearly in the plugin code.  The only parameter I can pass into the function is a callback function, which you can see is called "initCallback" in the code above.

 

I put the whole sample project with my workaround here: https://github.com/tonygod/CoronaGameCircleDemo

I/System.out(18536): SignedInCallbackNum: -1
I/Corona  (18536): ERROR: Runtime error
I/Corona  (18536): /Users/tonygod/Library/Application Support/luaglider2/dev/ProjectBuilds/Gamecircle(Builds)/Gamecircle(default)/Gamecircle/main.lua:364: java.lang.NullPointerException
I/Corona  (18536): Java Stack Trace:
I/Corona  (18536): 	plugin.gamecircle.LuaLoader.SetSignedInListener(LuaLoader.java:1383)
I/Corona  (18536): 	plugin.gamecircle.LuaLoader$SetSignedInListenerWrapper.invoke(LuaLoader.java:2393)
I/Corona  (18536): 	com.ansca.corona.JavaToNativeShim.nativeResize(Native Method)
I/Corona  (18536): 	com.ansca.corona.JavaToNativeShim.resize(JavaToNativeShim.java:381)
I/Corona  (18536): 	com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onSurfaceChanged(CoronaGLSurfaceView.java:378)
I/Corona  (18536): 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1612)
I/Corona  (18536): 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)
I/Corona  (18536): stack traceback:
I/Corona  (18536): 	[C]: in function 'SetSignedInListener'
I/Corona  (18536): 	/Users/tonygod/Library/Application Support/luaglider2/dev/ProjectBuilds/Gamecircle(Builds)/Gamecircle(default)/Gamecircle/main.lua:364: in main chunk



[TOPIC: post.html]
#6

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 542 posts
  • Corona Staff

Yes, this is exactly that. The plugin does not provide an init callback - a function which is called when initialization process is finished, so you have to wait for it using a timer.
When you try to call SetSignedInListener right after Init, an internal plugin's object is still null, so it fails.




[topic_controls]
[/topic_controls]