• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android GooglePlayServicesExtension.onActivityResult - java.lang.NullPointerException

Hello everyone,

Recently I have seen a large increase in "java.lang.NullPointerException" causing "java.lang.RuntimeException" errors for YYC Android compiled apk.

Has anyone else seen this, or had any experience with it?

I have highlighted where the issue starts.

Here is the Stack Trace:
java.lang.RuntimeException:
at android.app.ActivityThread.deliverResults (ActivityThread.java:5324)
at android.app.ActivityThread.handleSendResult (ActivityThread.java:5365)
at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2261)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:237)
at android.app.ActivityThread.main (ActivityThread.java:8107)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
Caused by: java.lang.NullPointerException:
at wave10.co.uk.wave10.Power_Volt.GooglePlayServicesExtension.onActivityResult (GooglePlayServicesExtension.java:255)
at wave10.co.uk.wave10.Power_Volt.RunnerActivity.onActivityResult (RunnerActivity.java:1201)
at android.app.Activity.dispatchActivityResult (Activity.java:8294)
at android.app.ActivityThread.deliverResults (ActivityThread.java:5317)

And here is the Java code it relates to:
Java:
@Override
    public  void onActivityResult(int requestCode, int responseCode, Intent intent)
    {
        Log.i("yoyo","gps onActivityResult called. RequestCode: "+requestCode + ". ResponseCode: " + responseCode);
        
        switch (requestCode) 
        {
            case RC_SIGN_IN:
                mSignInClicked = false;
                
                GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(intent);
                
                if (result.isSuccess())  // THIS IS LINE 255 (WHERE THE ERROR HAPPENS) <<<<<<<<<<<<<< !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                {
                    // The signed in account is stored in the result.
                    mGoogleSignInAccount = result.getSignInAccount();
                    onLoginSuccess(mGoogleSignInAccount);
                }
                else
                {
                    String message = result.getStatus().getStatusMessage();
                    int statuscode = result.getStatus().getStatusCode();
                    boolean hasresolution = result.getStatus().hasResolution();
                    
                    if (message == null || message.isEmpty())
                    {
                        Log.i("yoyo", "signInResult:failed, no status message returned. Status Code:"+statuscode +" Has resolution:" + hasresolution);
                    }
                    else
                    {
                        Log.i("yoyo", "signInResult:failed:"+message+" Status Code:"+statuscode+" Has resolution:" + hasresolution);
                        
                    }
                    onLoginFailed();
                }
                              
            break;
            
            case RC_GPS_ACTIVITY:
            {
                
                if(responseCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED)
                {
                    Log.i("yoyo","Activity result resulted in reconnect required");
                    Logout();
                }
            }
            break;
            
            default:
                Log.i("yoyo","onActivityResult called with " + requestCode);
                    break;
        }
    }
 
Just to mention so it's clearer this looks to be an issue with the GooglePlayServicesExtension just in case anyone is troubleshooting something similar...
 

SnoutUp

Member
Oh, this is good to know since I just planned to try out YYC builds on Android. I guess you could wrap that code part related to GoogleSignInResult with "if (result != null) {}" and hope that it's enough.
 
Oh, this is good to know since I just planned to try out YYC builds on Android. I guess you could wrap that code part related to GoogleSignInResult with "if (result != null) {}" and hope that it's enough.
Yeah I applied an update and wrapped that code last night. If it looks to fix it I will update this thread.
I was hoping to understand why it returned 'null' rather than patch it up, but as long as it fixes the crashes I'm happy.
 
Just to confirm, encasing the code with a null check did the job.
In case anyone needs it, here is the replacement code for the GooglePlayServicesExtension.java:

You should be able to find this case in the switch and just replace it. The error has not appeared for 3 days since this change.

Java:
case RC_SIGN_IN:
    mSignInClicked = false;

    GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(intent);

    if (result != null) {
        if (result.isSuccess()) // THIS IS LINE 255 (WHERE THE ERROR HAPPENS)
        {
            // The signed in account is stored in the result.
            mGoogleSignInAccount = result.getSignInAccount();
            onLoginSuccess(mGoogleSignInAccount);
        }
        else
        {
            String message = result.getStatus().getStatusMessage();
            int statuscode = result.getStatus().getStatusCode();
            boolean hasresolution = result.getStatus().hasResolution();

            if (message == null || message.isEmpty())
            {
                Log.i("yoyo", "signInResult:failed, no status message returned. Status Code:"+statuscode +" Has resolution:" + hasresolution);
            }
            else
            {
                Log.i("yoyo", "signInResult:failed:"+message+" Status Code:"+statuscode+" Has resolution:" + hasresolution);

            }
            onLoginFailed();
        }
    }
 
Top