playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.46k stars 967 forks source link

Games Native SDK Nearby #648

Closed AmelieBF closed 8 years ago

AmelieBF commented 9 years ago

Is there any way to get the messages from Native in Unity? I work on Nearby and sometimes some errors are log from native. For exemple: StartAdvertisingResult was given a null Java value. Returning error for operation. Base Java result of null was returned. Returning error for operation. AcceptConnectionRequestOperation returned an error from Java.

Thanks for your help!

claywilkinson commented 9 years ago

Can you provide an example of the logcat with these errors? That will help find where they are being logged. Thanks!

AmelieBF commented 9 years ago

sans titre For exemple this appen when I'im dicovering and I quit the game on my android device (press home menu)

AmelieBF commented 9 years ago

sans titre And when I'm advertising,I quit the game, and I come back to the game: the advertising result is "LicenseCheckFailed" and I have an exception. But the game doesn't crash. I strange because I stop the advertising prossess when I quit the game...

(The tags Unity are the logs I do from my game code)

Maybe I miss something when I made my game

claywilkinson commented 9 years ago

Can you save the log to a text file and paste it here to if it is too long, create a Gist?

tyrmullen commented 9 years ago

Yes-- you should be able to hook into all of the logging on Native through Unity and customize it fully. Inside of Platforms/Native/PInvoke/GameServicesBuilder.cs, call C.GameServices_Builder_SetOnLog to provide your own custom handler for the Native debug log messages (which will replace the default one you are seeing now).

AmelieBF commented 9 years ago

https://gist.github.com/AmelieBF/7392c2744614f0a94325

AmelieBF commented 9 years ago

sometimes I also have this crash: https://gist.github.com/AmelieBF/889ac8af1d85572ddba9 I don't know were it comes from...

AmelieBF commented 9 years ago

I don't know if it's possible but it seems like I try to make some things in Unity but not everything is done in the native code

tyrmullen commented 9 years ago

When you leave the game, the Android Nearby services stop (the underlying GoogleApiClient disconnects); any Nearby-related calls made after that will fail or error out until the OnInitializationFinished callback is called again with a success status (basically you need to wait until the client reconnects before calling anything). So that's what is causing that exception to be printed out.

The LicenseCheckFailed looks like a bug in the Unity status code conversion process-- the real status that should be being returned is "InternalError", which is consistent with the case above. I don't see any place where we would have an error message like "LicenseCheckFailed !!!!!" though-- is that getting printed out from your own error logging?

The second crash is occurring in Native code-- a method is being called on a Java object but that Java object is null. Starting with the "Nearby Init Complete" debug line and adding additional Unity debug logs moving forward might help pinpoint where exactly the method is being called or what is null. If you have steps to reproduce this (or a simple sample program), this would be good to track down.

AmelieBF commented 9 years ago

Thanks for your reply. Conserning the first step I will try to modifie my code in order to wait for the client connection.

The message is printed from when I get the response status in OnAdvertisingResult. I simply do that: void OnAdvertisingResult(AdvertisingResult result) { Debug.Log("OnAdvertisingResult: " + result.Status);

    if (result.Succeeded) {
        Debug.Log ("Advertiding OK");
    } 

    if(result.Status.Equals(GooglePlayGames.BasicApi.ResponseStatus.InternalError))
    {
        Debug.LogError ("Internal error!!!!!!!!");
    }
    if(result.Status.Equals(GooglePlayGames.BasicApi.ResponseStatus.LicenseCheckFailed))
    {
        Debug.LogError ("LicenseCheckFailed !!!!!!!!");
    }
    if(result.Status.Equals(GooglePlayGames.BasicApi.ResponseStatus.NotAuthorized))
    {
        Debug.LogError ("NotAuthorized");
    }
    if(result.Status.Equals(GooglePlayGames.BasicApi.ResponseStatus.Timeout))
    {
        Debug.LogError ("Timeout");
    }
    if(result.Status.Equals(GooglePlayGames.BasicApi.ResponseStatus.VersionUpdateRequired))
    {
        Debug.LogError ("VersionUpdateRequired");
    }
}

And concerning the crash, I'll try to log more things. If you want I can send you my Unity projet

Thanks for your help!

claywilkinson commented 8 years ago

OK to close this one?

AmelieBF commented 8 years ago

Yes!

claywilkinson commented 8 years ago

Thanks!