playgameservices / play-games-plugin-for-unity

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

Can't register class #998

Closed ethan-tqa closed 8 years ago

ethan-tqa commented 8 years ago

The issue is as stated, some classes cannot be registered, the list is below. I'm using Unity 4.6.6, plugin ver 0.9.31, support repository 25, google play services ver 29. I tried to run Android setup in unity, the results all look normal.

E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/Games$GetServerAuthCodeResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/PlayerLevel: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/PlayerLevelInfo: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/event/Event: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/event/EventBuffer: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/event/Events: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/event/Events$LoadEventsResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Quest: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/QuestBuffer: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Quests: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Milestone: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Quests$LoadQuestsResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Quests$AcceptQuestResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/quest/Quests$ClaimMilestoneResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/Snapshot: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/SnapshotContents: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/SnapshotMetadata: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/SnapshotMetadataBuffer: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/Snapshots: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/Snapshots$CommitSnapshotResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/Snapshots$LoadSnapshotsResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/Snapshots$OpenSnapshotResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/SnapshotMetadataChange: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/snapshot/SnapshotMetadataChange$Builder: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/stats/PlayerStats: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/stats/Stats: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/games/stats/Stats$LoadPlayerStatsResult: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/nearby/Nearby: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/nearby/connection/AppIdentifier: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/nearby/connection/AppMetadata: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/nearby/connection/Connections: an exception occurred. E/GamesNativeSDK(26091): Can't register class com/google/android/gms/nearby/connection/Connections$StartAdvertisingResult: an exception occurred.

alexchux commented 8 years ago

I have same issue with google play services ver 29 Unity 4.7.0 and plugin ver 0.9.3a Numerous reimports of plugin didn't help. Assets\Plugins\google-play-services_lib directory is in project Assets\Plugins\android-support-v4-22.2.1.jar also there

alexchux commented 8 years ago

Already have checked other threads about this issue, tried to reimport the plugin nothing seams to help

claywilkinson commented 8 years ago

These classes are in a more recent version of play-services-games and play-services-nearby. You'll need to update the Google repository, Android Support repository and Android platform components in SDK manager.

Then run Window > Google Play Games > Setup > Android Setup. Confirm that this makes several directories in Assets/Plugins/Android/play-services-*

You should not have Assets\Plugins\google-play-services_lib directory in the project.

ethan-tqa commented 8 years ago

I do not have Assets\Plugins\google-play-services_lib directory, and also do not have Assets/Plugins/Android/play-services-*, even after running Android setup. What is the required version for Google repository, Android Support repository and Android platform components?

claywilkinson commented 8 years ago

Google Repository should be at least version 24 Android Support Repository should be at least version 25

ethan-tqa commented 8 years ago

Everything I have satisfies the requirements, still having this issue

claywilkinson commented 8 years ago

@ethan-tqa - Can you share the contents of your Assets/Plugins/Android?

artakino commented 8 years ago

I'm having a very similar issue. I'm using Unity 4.7.0f1, plugin ver 0.9.31a. I have a directory named Assets/Plugins/Android/google-play-services_lib but no files or directories named Assets/Plugins/Android/play-services-* even thought I ran the setup number of times.

Google Repository version is 24, and Android Support Repository, which I believe is now named Local Maven repository, is version 26.

Here is what I get in the log:

E/GamesNativeSDK(10602): Can't register class com/google/android/gms/games/Games$GetServerAuthCodeResult: an exception occurred. E/GamesNativeSDK(10602): Can't register class com/google/android/gms/games/stats/PlayerStats: an exception occurred. E/GamesNativeSDK(10602): Can't register class com/google/android/gms/games/stats/Stats: an exception occurred. E/GamesNativeSDK(10602): Can't register class com/google/android/gms/games/stats/Stats$LoadPlayerStatsResult: an exception occurred. D/Unity (10602): Building GPG services, implicitly attempts silent auth: 0 at /Users/builduser/buildslave/unity/build/artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp:56 (17408, 0, 0) I/Unity (10602): Building GPG services, implicitly attempts silent auth I/Unity (10602): UnityEngine.Debug:Internal_Log(Int32, String, Object) I/Unity (10602): UnityEngine.Debug:Log(Object) I/Unity (10602): GooglePlayGames.Native.NativeClient:InitializeGameServices() (at /Users/Art/Projects/proj1/Assets/GooglePlayGames/Platforms/Native/NativeClient.cs:196) I/Unity (10602): GooglePlayGames.Native.NativeClient:Authenticate(Action1, Boolean) (at /Users/Art/Projects/proj1/Assets/GooglePlayGames/Platforms/Native/NativeClient.cs:130) I/Unity (10602): GooglePlayGames.PlayGamesPlatform:Authenticate(Action1, Boolean) (at /Users/Art/Projects/proj1/Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:368) I/Unity (10602): GooglePlayGames.PlayGamesPlatform:Authenticate(Action1) (at /Users/Art/Projects/proj1/Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:337) I/Unity (10602): GooglePlayGames.PlayGamesLocalUser:Authenticate(Action1) (at /Users/Art/Projects/proj1/Assets/GooglePlayGames/ISocialPlatform/PlayGamesLocalUser.cs:49) I/Unity (10602): MyGameServices:Init() (at /Users/Art/Projects/proj1/Assets/Scripts/Game/MyGameServices.cs:381) I/Unity (10602): GameState:In E/GamesNativeSDK(10602): Could not register one or more required Java classes. I/Unity (10602): InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK I/Unity (10602): at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x0003f] in /Users/Art/Projects/proj1/Assets/GooglePlayGames/Platforms/Native/PInvoke/GameServicesBuilder.cs:196 I/Unity (10602): at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x000c0] in /Users/Art/Projects/proj1/Assets/GooglePlayGames/Platforms/Native/NativeClient.cs:198 I/Unity (10602): at GooglePlayGames.Native.NativeClient.Authenticate (System.Action1 callback, Boolean silent) [0x00099] in /Users/Art/Projects/proj1/Assets/GooglePlayGames/Platforms/Native/NativeClient.cs:130 I/Unity (10602): at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action1 callback, Boolean silent) [0x00026] in /Users/Art/Projects/proj1/Assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:368 I/Unity (10602): at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action1 callback) [0x00000] in /Users/`

ethan-tqa commented 8 years ago

since the creation of this issue, I have moved my project to Unity 5.3.2, and reworked all the plugins integration, which kinda solved the problem. One thing to note is that after running Android setup, if the tool asks if you want to replace a couple of libraries to version 8.4.0 you must accept it. Also, play-services-ads from another plugin must be version 8.4.0 too to avoid collision.

artakino commented 8 years ago

Thanks Ethan, but it hasn't asked me to replace any libraries. And moving to Unity 5.x is not an option for me at the moment.

ethan-tqa commented 8 years ago

Do you see exception thrown from Resolver? if you do, try to edit the PlayServicesResolver class, getter static IResolver Resolver, assign a new instance of ResolverVer1_1 directly to _resolver. The tool should ask you about it after that (if you don't have the latest version already). Do remember to delete the line that tries to resolve type by name.

artakino commented 8 years ago

I did get a related exception at some point but it only happened once and since it hasn't happened again. However, I did try to simply assign an instance of ResolverVer1_1 directly and it did not make any difference. So I'm assuming I have the latest version already.

I also tried removing android-support-v4.jar from the project in case it was an older version. But that also made no difference. I'm assuming that this library is automatically fetched from the android directory at build time regardless.

So far no luck.

artakino commented 8 years ago

Finally found the solution. Even though I had the latest versions of Google Repository and Android Support Repository, Unity was still seeing the older versions because the android-support-v4.jar and google-play-services.jar files in the Assets/Plugins/Android/ directory were old. Running Window > Google Play Games > Setup > Android Setup wasn't doing anything for me. So I manually copied the new .jar files form the android folder into Assets/Plugins/Android/ replacing the old ones. And finally, I updated "google_play_services_version" in the version.xml and it all work great! Thanks for you help Ethan.

claywilkinson commented 8 years ago

@ethan-tqa - what version of play-services-games is being included into Assets/Plugins/Android?

ethan-tqa commented 8 years ago

play-services-games 8.4.0