[Xamarin.Android.Build.Tasks] fix proguard rules for R8 compatibility #2735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: https://www.guardsquare.com/en/products/proguard/manual/usage#keepoptionmodifiers
Context: https://www.guardsquare.com/en/products/proguard/manual/examples
Fixes: #2684
Using R8 on a pre-Android 8.0 device was crashing with:
Looking into it, the following method was present when using ProGuard,
but not R8:
Then I looked at
proguard_xamarin.cfg
, and noticed something strange:It seemed this rule was being ignored? All the other working rules
were using
<init>(...);
to refer to the instance constructor.When I reviewed ProGuard's documented syntax/grammar:
It seems
(...)
is the proper way to specify a match against any setof arguments. Looking through ProGuard's examples, I can't find any
usage of
(***)
. It must happen to work, but is undocumented.R8 does not appear to accept the
(***)
syntax at all.Other changes
I expanded upon the
DexUtils
class so it can look for methods withinclasses. I also adjusted one test to verify this problem is solved.
For comparison, attached dexdump output