playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.45k stars 962 forks source link

Autentication never true #1053

Closed Ghislo749 closed 8 years ago

Ghislo749 commented 8 years ago

Actually my Activate function is onAwake() and I call the Autentication onStart() but the auth always fail without even trying. I set on Saved Games on console and checked all codes are correct.. any other question helped me, any advice!?

claywilkinson commented 8 years ago

Can you share the log during the startup and authentication? Usually there is a clue in the log that helps.

Ghislo749 commented 8 years ago

The debug gives three logs before the autentication "fail" log

1)

[Play Games Plugin DLL] 03/15/16 21:57:30 +01:00 DEBUG: Creating platform-specific Play Games client. UnityEngine.Debug:Log(Object) GooglePlayGames.OurUtils.Logger:d(String) (at Assets/GooglePlayGames/OurUtils/Logger.cs:59) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:362) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:337) GameHandler:Start() (at Assets/Scripts/GameHandler.cs:60)

2)

[Play Games Plugin DLL] 03/15/16 21:57:30 +01:00 DEBUG: Creating IPlayGamesClient in editor, using DummyClient. UnityEngine.Debug:Log(Object) GooglePlayGames.OurUtils.Logger:d(String) (at Assets/GooglePlayGames/OurUtils/Logger.cs:59) GooglePlayGames.PlayGamesClientFactory:GetPlatformPlayGamesClient(PlayGamesClientConfiguration) (at Assets/GooglePlayGames/Platforms/PlayGamesClientFactory.cs:31) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:364) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:337) GameHandler:Start() (at Assets/Scripts/GameHandler.cs:60)

3)

[Play Games Plugin DLL] 03/15/16 21:57:30 +01:00 DEBUG: Received method call on DummyClient - using stub implementation. UnityEngine.Debug:Log(Object) GooglePlayGames.OurUtils.Logger:d(String) (at Assets/GooglePlayGames/OurUtils/Logger.cs:59) GooglePlayGames.BasicApi.DummyClient:LogUsage() (at Assets/GooglePlayGames/BasicApi/DummyClient.cs:521) GooglePlayGames.BasicApi.DummyClient:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/BasicApi/DummyClient.cs:47) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:368) GooglePlayGames.PlayGamesPlatform:Authenticate(Action`1) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:337) GameHandler:Start() (at Assets/Scripts/GameHandler.cs:60)

and then the debug log of the "fail" :

Failed loggin UnityEngine.Debug:Log(Object) GameHandler:m__E8(Boolean) (at Assets/Scripts/GameHandler.cs:65) GooglePlayGames.BasicApi.DummyClient:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/BasicApi/DummyClient.cs:50) GooglePlayGames.PlayGamesPlatform:Authenticate(Action1, Boolean) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:368) GooglePlayGames.PlayGamesPlatform:Authenticate(Action`1) (at Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:337) GameHandler:Start() (at Assets/Scripts/GameHandler.cs:60)

If you need the code being used is this :


void Awake() {
        // Activate the Google Play Games platform
        PlayGamesPlatform.Activate ();
        PlayGamesPlatform.DebugLogEnabled = true;
    }

    // Use this for initialization
    void Start () {

        GooglePlayGames.PlayGamesPlatform.Instance.Authenticate ((bool success) => {
            // handle success or failure
            if(success) {
                Debug.Log ("LOGGED");
            } else {
                Debug.Log("Failed loggin");
            }
        });

}
claywilkinson commented 8 years ago

The plugin does not work in the editor. You need to test it on an actual device. Creating IPlayGamesClient in editor, using DummyClient.

Ghislo749 commented 8 years ago

It doesn't work on the device neither

I'm testing on a Samsung Galaxy s5.

What I did so far is checking the SHA1 and it's correct. I checked if the play game service ID of my game in the android manifest is correct and it is. I tryed changing a bit the code like he (https://github.com/playgameservices/play-games-plugin-for-unity/issues/344) did and play a bit around with it, but nothing seemed to work.

Oh and I forgot, at the beginning it gave me an error while building and to solve it i had to put inside my android folder in the assets the google-play-services-lib folder taken from my SDK.

I also Updated SDK, Google play lib etc etc in "extras" section of sdk.

And lastly i tryed reimporting the plugin in unity...

I really don't know what else to try :(

claywilkinson commented 8 years ago

Can you share the the log from the device?

Ghislo749 commented 8 years ago
`D/InputReader(  883): Input event: value=1

I/InputReader(  883): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.8296 ] when=45486504013000

I/InputDispatcher(  883): Delivering touch to: action: 0x0, toolType: 1

D/InputReader(  883): Input event: value=0

I/InputReader(  883): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=45486578820000

I/InputDispatcher(  883): Delivering touch to: action: 0x1, toolType: 1

I/GamesNativeSDK( 7366): Auth operation started: SIGN IN

I/GamesNativeSDK( 7366): Connecting to Google Play...

I/Unity   ( 7366):  [Play Games Plugin DLL] 03/15/16 23:20:04 +01:00 DEBUG: Activating PlayGamesPlatform.

I/Unity   ( 7366):

I/Unity   ( 7366): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

I/Unity   ( 7366):

I/Unity   ( 7366):  [Play Games Plugin DLL] 03/15/16 23:20:04 +01:00 DEBUG: PlayGamesPlatform activated: GooglePlayGames.PlayGamesPlatform

I/Unity   ( 7366):

I/Unity   ( 7366): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

I/Unity   ( 7366):

E/GamesNativeSDK( 7366): Not authorizing: no client.

I/Unity   ( 7366):  [Play Games Plugin DLL] 03/15/16 23:20:04 +01:00 DEBUG: Starting Auth Transition. Op: SIGN_IN status: ERROR_NOT_AUTHORIZED

I/Unity   ( 7366):

I/Unity   ( 7366): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

I/Unity   ( 7366):

I/Unity   ( 7366): AuthState == Unauthenticated calling auth callbacks with failure

I/Unity   ( 7366):

I/Unity   ( 7366): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

I/Unity   ( 7366):

I/Unity   ( 7366):  [Play Games Plugin DLL] 03/15/16 23:20:04 +01:00 DEBUG: Invoking user callback on game thread

I/Unity   ( 7366):

I/Unity   ( 7366): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

I/Unity   ( 7366):`
Ghislo749 commented 8 years ago

It seems like the client is not authorized, but because of what? I'm sure the ID, Auth2 codes are right.. the keystore is.. I really don't know. I checked the SHA1 that i didn't know and it came out it automatically was set right... i don't know

claywilkinson commented 8 years ago

This line E/GamesNativeSDK( 7366): Not authorizing: no client. usually means Activate() was not called. Can you share the log from starting the application (when Awake() would be called?)

Ghislo749 commented 8 years ago

Ok the log is huge but i read some errors indicating that E/dalvikvm( 9212): Could not find class 'android.support.v4.util.ArrayMap', referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.<init>

seems like i'm missing this android.supporv4 asset, could it be my problem?

claywilkinson commented 8 years ago

Yes it definitely is a problem. You don't need google-play-services-lib this is replaced by the .aar files. You should delete Assets/Plugins/Android/google-play-services-lib. Then run Window > Google Play Games > Setup > Android Setup. Pasting in your resources xml file.

This should run with no errors. It will add several files to Assets/Plugins/Android which should have:

MainLibProj
libs
play-services-base-8.5.3.aar
play-services-basement-8.5.3.aar
play-services-drive-8.5.3.aar
play-services-games-8.5.3.aar
play-services-nearby-8.5.3.aar
play-services-plus-8.5.3.aar
support-annotations-23.2.1.jar
support-v4-23.0.0.aar

If it does not, try running Assets > Play Services > Resolve Client Jars. There should be no errors in the console.

Ghislo749 commented 8 years ago

Yeah I needed it beacause it solved a problem that occurred with Unity Ads interacting somehow with PlayGamesPlugin, btw now I try and let you know.

Ghislo749 commented 8 years ago

Ok I noticed that my .aar files all have the -8.4.0 at the end, but they are all there. Second: When i try resolving client jars it says me : "JAVA_HOME environment variable must be set"

claywilkinson commented 8 years ago

If there is an error with Unity ads when using the .aars, which class or resource cannot be found? You can add the .aar that it needs to resolve the problem.

claywilkinson commented 8 years ago

Which version of Unity are you using (4.x?) You need to set JAVA_HOME in your system environment. To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.

Once it is set, exit Unity and restart, then try to resolve the client jars again.

Ghislo749 commented 8 years ago

The version of Unity is 4.7.1f1 I set the JAVA_HOME variable in the system environment variables, restarted, now the log gives me a log and an error when trying to resolve jars: LOG)

System.ComponentModel.Win32Exception: ApplicationName='C:\Program Files\Java\java\jdk1.7.0_79\bin\jar.exe', CommandLine='xvf "C:\Users\ricca\Documents\Gimmey\Assets\Plugins\Android\play-services-base-8.4.0.aar"', CurrentDirectory='C:\Users\ricca\Documents\Gimmey\Assets\Plugins\Android\play-services-base-8.4.0'
  at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
  at GooglePlayServices.DefaultResolver.ProcessAar (System.String dir, System.String aarFile) [0x000e4] in C:\Users\ricca\Documents\Gimmey\Assets\PlayServicesResolver\Editor\DefaultResolver.cs:213 
UnityEngine.Debug:Log(Object)
GooglePlayServices.DefaultResolver:ProcessAar(String, String) (at Assets/PlayServicesResolver/Editor/DefaultResolver.cs:269)
GooglePlayServices.ResolverVer1_1:ProcessAars(String) (at Assets/PlayServicesResolver/Editor/ResolverVer1_1.cs:97)
GooglePlayServices.ResolverVer1_1:DoResolution(PlayServicesSupport, String, OverwriteConfirmation) (at Assets/PlayServicesResolver/Editor/ResolverVer1_1.cs:71)
GooglePlayServices.PlayServicesResolver:MenuResolve() (at Assets/PlayServicesResolver/Editor/PlayServicesResolver.cs:144)

ERROR)

Win32Exception: ApplicationName='C:\Program Files\Java\java\jdk1.7.0_79\bin\jar.exe', CommandLine='xvf "C:\Users\ricca\Documents\Gimmey\Assets\Plugins\Android\play-services-base-8.4.0.aar"', CurrentDirectory='C:\Users\ricca\Documents\Gimmey\Assets\Plugins\Android\play-services-base-8.4.0'
System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
System.Diagnostics.Process.Start ()
(wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
GooglePlayServices.DefaultResolver.ProcessAar (System.String dir, System.String aarFile) (at Assets/PlayServicesResolver/Editor/DefaultResolver.cs:213)

I don't really understand this one error

Ghislo749 commented 8 years ago

Can't I import manually the .aar 's ?

claywilkinson commented 8 years ago

I don't see the error message, just that there was a problem. Did it process any of the aar files correctly?

You can manually do the steps in Assets/PlayServicesResolver/Editor/DefaultResolver.cs

At a high level:

  1. unzip the aar file into a directory with the name of the aar. you can do this using jar xvf
  2. create a project.properties file as shown in the code.
  3. move the classes to the lib directory.
Ghislo749 commented 8 years ago

None of them, it stops at the first of them, the -base one. They are all still 8.4.0.

Tomorrow I'll try doing what you say, but I have some doubts. Will it work with these 8.4.0 aar files instead of 8.5.3 as you said? (and why in the world I have these 8.4.0 if I downloaded the last version of the plugin). If I do this process you say, in the end I'll have a classes.jar and a project.properties containing all of the aar 's information or i'll have one classes.jar and project.properties for each aar file? (each in a directory with same name of the aar file)

isn't there any other solution? I gotta go now, I gotta sleep, I'll be having a class in university in some few hours.. the problem is that I'll by far from home for some day after tomorrow, so I won't have time to work on this until next monday.. so you probably won't hear anything from me until then.

If something comes to your mind let me know. Thank you, really disponible and prepared, I hope I'll get to fix this :) Have a nice day!

Ghislo749 commented 8 years ago

I DID IT!!! I can't believe it I'm almost crying... aaahha I just installed the latest jdk for x86 (I was using x64) and set the JAVA_HOME to that jdk directory, then the jar resolver worked fine and now i got my classes working fine. Thank you a lot! Maybe there is an issue with jdk x64, worth giving it a look! ;)

claywilkinson commented 8 years ago

Great news! I am glad you got it working!