playgameservices / play-games-plugin-for-unity

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

Proguard rules need updating #2618

Closed Spud6703 closed 4 years ago

Spud6703 commented 5 years ago

I've added the Proguard rules to my Unity Android project from here:

https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/scripts/proguard.txt

but the sign in fails. If I build without ProGuard then the sign in works fine so Proguard is screwing things up. I have to use Proguard though because if I don't I get "Cannot fit requested classes in a single dex file (# methods: 75537 > 65536)". I had to remove all my advertising SDKs from Unity in order to carry out the test without Proguard. Here are some errors in my logcat file that seem to be Proguard related. I don't really understand what Proguard does so .... HELP !!!!!

Look for the "Can't register class" sections:

06-28 19:12:13.573 20744-20953/? W/Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed 06-28 19:12:13.573 20744-20953/? W/Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@14799003@14.7.99 (000306-223214910):2) 06-28 19:12:13.573 20744-20953/? W/Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@14799003@14.7.99 (000306-223214910):2) 06-28 19:12:13.793 20744-26897/? W/GamesServiceBroker: Client connected with SDK 15022000, Services 14799003, and Games 78250036 06-28 19:12:13.793 20744-21038/? W/GamesServiceBroker: Client connected with SDK 15022000, Services 14799003, and Games 78250036 06-28 19:12:13.963 1760-1760/? W/SignInActivity: onSignInFailed()... 06-28 19:12:13.963 1760-1760/? W/SignInActivity: Sign in failed during 6 06-28 19:12:13.963 1760-1760/? W/SignInActivity: ==> Returning non-OK result: 10002 06-28 19:12:13.963 20744-20755/? W/GamesServiceBroker: Client connected with SDK 15022000, Services 14799003, and Games 78250036 06-28 19:12:13.993 1712-1712/? W/AutoManageHelper: Unresolved error while connecting client. Stopping auto-manage. 06-28 19:12:14.053 3352-3352/? E/TokenFragment: Setting result error status code to: 16 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/GooglePlayServicesUtil: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/Api: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/Api$ApiOptions: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/Api$ApiOptions$HasOptions: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/GoogleApiClient: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/GoogleApiClient$Builder: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/PendingResult: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/api/Result: an exception occurred. 06-28 19:12:14.173 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/common/data/DataBufferUtils: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Quest: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/QuestBuffer: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Quests: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Milestone: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Quests$LoadQuestsResult: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Quests$AcceptQuestResult: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/games/quest/Quests$ClaimMilestoneResult: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/nearby/Nearby: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/AppIdentifier: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/AppMetadata: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/Connections: an exception occurred. 06-28 19:12:14.184 3352-3352/? E/GamesNativeSDK: Can't register class com/google/android/gms/nearby/connection/Connections$StartAdvertisingResult: an exception occurred. 06-28 19:12:14.254 3352-3352/? E/GamesNativeSDK: Could not register one or more required Java classes. 06-28 19:12:14.434 3352-3352/? E/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) [0x0002a] in <6fc4e8416db645d685c49e207afba2d8>:0 at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x000e9] in <6fc4e8416db645d685c49e207afba2d8>:0 at GooglePlayGames.Native.NativeClient+<>c__DisplayClass21_0.<Authenticate>b__0 (System.Int32 result) [0x00000] in <6fc4e8416db645d685c49e207afba2d8>:0 at GooglePlayGames.Android.AndroidTokenClient+<>c__DisplayClass26_0.<DoFetchToken>b__0 (UnityEngine.AndroidJavaObject tokenResult) [0x00067] in <6fc4e8416db645d685c49e207afba2d8>:0 at GooglePlayGames.Android.AndroidTokenClient+ResultCallbackProxy.onResult (UnityEngine.AndroidJavaObject tokenResult) [0x00000] in <6fc4e8416db645d685c49e207afba2d8>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.Mo 06-28 19:12:14.474 564-577/? E/qcom_sensors_hal: hal_process_report_ind: Bad item quality: 11 06-28 19:12:14.494 564-577/? E/qcom_sensors_hal: hal_process_report_ind: Bad item quality: 11 06-28 19:12:14.514 564-577/? E/qcom_sensors_hal: hal_process_report_ind: Bad item quality: 11 06-28 19:12:14.534 564-577/? E/qcom_sensors_hal: hal_process_report_ind: Bad item quality: 11 06-28 19:12:14.554 564-577/? E/qcom_sensors_hal: hal_process_report_ind: Bad item quality: 11 06-28 19:12:14.784 3352-3427/? E/Unity: java.io.EOFException

Spud6703 commented 5 years ago

Actually, is there any way to remove the Google Play Services APIs that I don't need without resorting to Proguard which seems to remove all sorts of classes from all the other plugins I'm using? Maybe a post build script or something that removes Google APIs such as the Panorama Viewer "com.google.android.gms:play-services-panorama:17.0.0" from the build before the apk is built? I just need to get the number of classes below 65536 so this Dex thing doesn't barf.

ozdemir08 commented 5 years ago

Can you try Proguard configs below and let me know if you have any issues about games services?

-keep class com.google.android.gms.games.multiplayer.** { *; }
-keep class com.google.android.gms.games.leaderboard.** { *; }
-keep class com.google.android.gms.games.snapshot.** { *; }
-keep class com.google.android.gms.games.achievement.** { *; }
-keep class com.google.android.gms.games.event.** { *; }
-keep class com.google.android.gms.games.stats.** { *; }
-keep class com.google.android.gms.games.video.** { *; }
-keep class com.google.android.gms.games.* { *; }
-keep class com.google.android.gms.common.api.ResultCallback { *; }
-keep class com.google.android.gms.signin.** { *; }
-keep class com.google.android.gms.dynamic.** { *; }
-keep class com.google.android.gms.dynamite.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
-keep class com.google.android.gms.security.** { *; }
-keep class com.google.android.gms.base.** { *; }
-keep class com.google.android.gms.actions.** { *; }
-keep class com.google.games.bridge.** { *; }

-keep class com.google.android.gms.common.ConnectionResult { *; }
-keep class com.google.android.gms.common.GooglePlayServicesUtil { *; }
-keep class com.google.android.gms.common.api.** { *; }
-keep class com.google.android.gms.common.data.DataBufferUtils { *; }
-keep class com.google.android.gms.games.quest.** { *; }
-keep class com.google.android.gms.nearby.** { *; }

Also, if you get "Can't register class" errors for any other package, you can add a keep rule for them in this format -keep class com.example.package.** { *; }.