playgameservices / play-games-plugin-for-unity

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

signin failed, InvalidOperationException: There was an error creating a GameServices object #572

Closed GeorgeDominic closed 9 years ago

GeorgeDominic commented 9 years ago

Signin failed this is the logcat info: 06-14 18:27:46.186 4948-4974/? W/Unity? !!! [Play Games Plugin DLL] 06/14/15 18:27:46 +05:30 WARNING: PlayGamesPlatform already initialized. Ignoring this call. (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-14 18:27:46.186 4948-4974/? I/Unity? [Play Games Plugin DLL] 06/14/15 18:27:46 +05:30 DEBUG: Activating PlayGamesPlatform. (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-14 18:27:46.186 4948-4974/? I/Unity? [Play Games Plugin DLL] 06/14/15 18:27:46 +05:30 DEBUG: PlayGamesPlatform activated: GooglePlayGames.PlayGamesPlatform (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-14 18:27:46.186 4948-4974/? E/GamesNativeSDK? Could not register one or more required Java classes. 06-14 18:27:46.186 4948-4974/? I/Unity? InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in :0 at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x00000] in :0 at GooglePlayGames.Native.NativeClient.Authenticate (System.Action1 callback, Boolean silent) [0x00000] in <filename unknown>:0 at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action1 callback, Boolean silent) [0x00000] in :0 at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action1 callback) [0x00000] in <filename unknown>:0 at GooglePlayGames.PlayGamesLocalUser.Authenticate (System.Action1 callback) [0x00000] in :0 at FirstRefillSelfDelete.SignIn () [0x00000] in :0 at FirstRefillSelfDelete.ManulPGPActivation () [0x00000] in <filename unkno

claywilkinson commented 9 years ago

06-14 18:27:46.186 4948-4974/? E/GamesNativeSDK? Could not register one or more required Java classes.

Earlier in the log, there should be some errors about registering java classes? To fix this make sure you have the latest play services SDK (in SDK manager, it is in the "Extras" section). and run the plugin setup again, Window > Google Play Games > Setup > Android Setup ...

GeorgeDominic commented 9 years ago

ok will try and see

GeorgeDominic commented 9 years ago

yes that worked well, I had to run plugin setup again. signin working now but I have an issue with opening saved games logcat: 06-15 15:08:28.545 21606-21623/? E/GamesNativeSDK﹕ Exception in dalvik/system/DexClassLoader.loadClass: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.NativeSdkEntryPoints" on path: /data/data/com.BassFlicks.ChristyTheRover/app_.gpg.classloader/de80b70ed0da0dfe988a41fa560612ee.jar. 06-15 15:08:28.568 21606-21623/? W/PopupManager﹕ You have not specified a View to use as content view for popups. Falling back to the Activity content view. Note that this may not work as expected in multi-screen environments 06-15 15:08:28.568 21606-21657/? I/GamesNativeSDK﹕ Auth operation started: SIGN IN 06-15 15:08:28.568 21606-21657/? I/GamesNativeSDK﹕ Connecting to Google Play... 06-15 15:08:28.576 21606-21657/? I/dalvikvm﹕ Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza 06-15 15:08:28.576 21606-21657/? W/dalvikvm﹕ VFY: unable to resolve virtual method 243: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder; 06-15 15:08:28.576 21606-21657/? D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x00c2 06-15 15:08:28.576 21606-21657/? I/dalvikvm﹕ DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras 06-15 15:08:28.576 21606-21657/? W/dalvikvm﹕ VFY: unable to resolve instance field 18 06-15 15:08:28.584 21606-21657/? D/dalvikvm﹕ VFY: replacing opcode 0x54 at 0x00e1 06-15 15:08:28.584 21606-21657/? E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza 06-15 15:08:28.584 21606-21657/? W/dalvikvm﹕ VFY: unable to resolve check-cast 24 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil; 06-15 15:08:28.584 21606-21657/? D/dalvikvm﹕ VFY: replacing opcode 0x1f at 0x000e 06-15 15:08:28.584 21606-21623/? I/Unity﹕ [Play Games Plugin DLL] 06/15/15 15:08:28 +05:30 DEBUG: Entering state: BeforeRoomCreateStartedState (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-15 15:08:28.584 21606-21623/? I/Unity﹕ [Play Games Plugin DLL] 06/15/15 15:08:28 +05:30 DEBUG: BeforeRoomCreateStartedState.OnStateEntered: Defaulting to no-op. (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-15 15:08:28.584 21606-21657/? I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh 06-15 15:08:28.584 21606-21657/? W/dalvikvm﹕ VFY: unable to resolve virtual method 510: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller; 06-15 15:08:28.584 21606-21657/? D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b 06-15 15:08:28.584 21606-21623/? I/Unity﹕ [Play Games Plugin DLL] 06/15/15 15:08:28 +05:30 DEBUG: Entering state: ShutdownState (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56) 06-15 15:08:28.584 21606-21623/? I/Unity﹕ [Play Games Plugin DLL] 06/15/15 15:08:28 +05:30 DEBUG: ShutdownState.OnStateEntered: Defaulting to no-op. (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 56)

GeorgeDominic commented 9 years ago

How to open a saved game which does not exist, for example a someone sigining into google play services for the first time. normally you would use Games.Snapshot.open(apiClient, filename, createIfNotFound); createIfNotFound will do the job but unity plugin has different methods and different ways of handling thing I think.

claywilkinson commented 9 years ago

From the log, it looks like SDKs may need to be updated? There are a lot of methods that look missing.

In the C++ SDK (and the Unity plugin), createIfNotFound is effectively always true, so you can call it with a filename that does not exist and open will succeed.

GeorgeDominic commented 9 years ago

I am trying to convert an object to byte array using the following C# code, but it is not working in Android, can you tell me what to do please. I want to save the obj to the GPS cloud

public static byte[] ObjectToByteArray(Object obj) { BinaryFormatter bf = new BinaryFormatter(); using (var ms = new MemoryStream()) { bf.Serialize(ms, obj); return ms.ToArray(); } } // Convert a byte array to an Object public static InventoryItems ByteArrayToObject(byte[] arrBytes) { using (var memStream = new MemoryStream()) { var binForm = new BinaryFormatter(); memStream.Write(arrBytes, 0, arrBytes.Length); memStream.Seek(0, SeekOrigin.Begin); InventoryItems obj =(InventoryItems) binForm.Deserialize(memStream); return obj; } }

claywilkinson commented 9 years ago

The way is done in the NearbyDroids sample is:

       private static BinaryFormatter bf = new BinaryFormatter();

        MemoryStream m = new MemoryStream();
        bf.Serialize(m, msg); 
        m.Flush();
        return m.ToArray();`

Then to deserialize:

        MemoryStream ms = new MemoryStream(data);
        GameDataMessage msg = bf.Deserialize(ms) as GameDataMessage;
GeorgeDominic commented 9 years ago

yup saved games working just fine I am able to serialize and deserialize objs, very cool thank you. please close this issue