googlesamples / google-signin-unity

Google Sign-In API plugin for Unity game engine. Works with Android and iOS.
Other
411 stars 225 forks source link

Proguard rules #159

Open ReGaSLZR opened 3 years ago

ReGaSLZR commented 3 years ago

Hi there!

Here's a screenshot from a crash scenario with a project with Google SignIn plugin on it. (The build is release-type and therefore needs Proguard rules.)

Screen Shot 2020-09-25 at 14 45 08

[EDIT: The crash happens when a user successfully logs in (via Google plugin, of course)]

So far, these are the entries on my Proguard.

-keep class com.android.* {*;}

-keep class com.unity3d.player.* { *; }
-keep class com.unity3d.plugin.* { *; }
-keep class com.unity3d.ads.** { *; }
-keep class com.unity3d.services.** { *; }

-dontwarn com.google.ar.core.**
-dontwarn com.unity3d.services.**
-dontwarn com.ironsource.adapters.unityads.**

-keep class android.* {*;}
-keep class com.android.* {*;}

-keep class com.google.* {*;}
-keep class com.google.firebase.* {*;}
-keep class com.google.googlesignin.* {*;}
-keep class com.google.android.* {*;}
-keep class com.google.android.gms.auth.* {*;}

-keep class com.google.nativelib.googlesignin.* {*;}

-keep class com.facebook.internal.* {*;}
-keep class com.facebook.unity.* {*;}

-keep class com.yasirkula.unity.* {*;}

But I feel like I'm still missing something since the logs say there's a missing method. So I come to ask, what are the exact Proguard entries for this plugin anyway? (I just guessed a bunch of them).

ReGaSLZR commented 3 years ago

I just tried

-keep class com.google.android.* {*;}

instead of

-keep class com.google.android.gms.auth.* {*;}

and yet, it still is crashing.

Any updates on this, guys? I just want your input on the Proguard rules for Google SignIn (Unity SDK). 😢

ReGaSLZR commented 3 years ago

I guess Google devs are busy.

I found a solution for this. Here are all the Google-related proguard rules in my project and am posting this for everyone's verification or reference:

-keep class com.google.* {*;}
-keep class com.google.impl.* {*;}
-keep class com.google.firebase.* {*;}
-keep class com.google.googlesignin.** { *; }
-keepnames class com.google.googlesignin.* { *; }
-keep class com.google.gms.** {*;}
-keep class com.google.android.gms.auth.** { *; }
-keep class com.google.android.* {*;}
-keep class com.google.unity.* {*;}

It now works on my end without crashing (on production build, proguard is turned on). In case I missed out some other important bits or there are some corrections, let me know. I just experimented on this myself.

//Not marking this ticket closed or fixed yet. Need verification from a Google dev if possible.

mudassar024 commented 3 years ago

Thanks man! you saved a life.

ReGaSLZR commented 3 years ago

Thanks man! you saved a life.

No problem, man! Glad to have helped. You have no idea how much pressure I got from my team when this issue was around and the Google devs were not responding at all. Still are.

lcd11001 commented 3 years ago

I guess Google devs are busy.

I found a solution for this. Here are all the Google-related proguard rules in my project and am posting this for everyone's verification or reference:

-keep class com.google.* {*;}
-keep class com.google.impl.* {*;}
-keep class com.google.firebase.* {*;}
-keep class com.google.googlesignin.** { *; }
-keepnames class com.google.googlesignin.* { *; }
-keep class com.google.gms.** {*;}
-keep class com.google.android.gms.auth.** { *; }
-keep class com.google.android.* {*;}
-keep class com.google.unity.* {*;}

It now works on my end without crashing (on production build, proguard is turned on). In case I missed out some other important bits or there are some corrections, let me know. I just experimented on this myself.

//Not marking this ticket closed or fixed yet. Need verification from a Google dev if possible.

can we use short template for all google classes like this?

-keep class com.unity3d.plugin.* { *; }
-keep class com.google.* { *; }
soumyadeep-ch commented 12 months ago

My proguard rules:-

-keep class com.unity.** { *;}
-keep class com.unity3d.plugin.* { *; }
-keep class com.google.** { *;}