I have hard time making my customer's app compile with proguard on (i installed the latest version of proguard in the correct folder). --edit--: i was not using the latest version as multiple copies were installed and the build script did not use the correct one.
I've created a proguard.cfg file which resolves most of compile errors. The app targets latest android SDK (8) and have a minSdk set to 21.
There is 2 compile errors left:
#1>PROGUARD : warning : com.google.android.gms.internal.zzx: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzx$zza
#1>PROGUARD : warning : com.google.android.gms.internal.zzx$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzx$zza
On stackoverflow, on java, they resolve the problem by adding something to Graddle. On Xamarin ... you can't.
I was able to ignore the 2 warnings by adding a dontwarn instruction in the proguard file.
It then compile, deploy and run nearly fine.
Nearly all the app does run fine.
Except:
- Google auth, crashing
- facebook auth, crashing
- Google location (fuse) crashing.
The crashes are caused by missing methods. Methods that have been removed by proguard.
For facebook:
NoSuchMethodError: no non-static method"Lcom/facebook/internal/CallbackManagerImpl;.onActivityResult(IILandroid/content/Intent;)Z"
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <e3048811891c45499b4d89daf4d10667>:0
at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <48117e3895d549baa70c8cbd8592b31c>:0
at Android.Runtime.JNIEnv.GetMethodID (System.IntPtr kls, System.String name, System.String signature) [0x00007] in <758a804725c84b16bcab28b784c87cae>:0
at Xamarin.Facebook.ICallbackManagerInvoker.OnActivityResult (System.Int32 requestCode, System.Int32 resultCode, Android.Content.Intent data) [0x00015] in <53b39e4821ad43cba06dc6bebd7ae5f1>:0
at Appname.Droid.Views.Signup.SignInActivity.OnActivityResult
For google auth:
NoSuchMethodError: no non-static method "Lcom/google/android/gms/auth/api/signin/internal/zzc;.silentSignIn(Lcom/google/android/gms/common/api/GoogleApiClient;)Lcom/google/android/gms/common/api/OptionalPendingResult;"
For google location (fuse):
NoSuchMethodError: no non-static method "Lcom/google/android/gms/internal/zzary;.requestLocationUpdates(Lcom/google/android/gms/common/api/GoogleApiClient;Lcom/google/android/gms/location/LocationRequest;Lcom/google/android/gms/location/LocationListener;Landroid/os/Looper;)Lcom/google/android/gms/common/api/PendingResult;"
I have also tryed with the preview nugets of google play services. No luck. Any idea how to resolve these errors ?
** EDIT 1 ** Using the link from John Douglas in the comments, and the links in the answer from eugen, and a detailed diagnostic build, after 2 hours of fixing errors the proguard file is finally working fine for both Facebook and Google SDK !
Ty so much !
This is proguard config from Facebook SDK for Android 4.23:
Source: facebook-android-sdk on Github
This is proguard config from Google Play services 11.2:
Source:
com.google.android.gms:play-services-basement:11.2.0
artifact from Google repoProguard setup for Google Play services is also described in Set Up Google Play Services > Add Google Play Services to Your Project > Other. The configuration looks a bit different from what's found in the library .aar, try this one first.