Search code examples
androidandroid-proguard

Proguard deletes method parameters


Recently I found very strange thing with ProGuard. I have this code snippet code snippet

As you can see, method showTipHoodLock takes 2 parameters, fragmentManager and top (some offset)

but after I compile the app with minifyEnabled true

I got this on click callback onClick callback

and this is Utils.showTipHoodLock method showTipHoodLock

As you can see, proguard deleted 2nd parameter (named top) from method signature and replaced its occurances with 0 literal.

Is it a bug, or a feature, or did I miss something?

P.S. If I change values in line

int coords[] = {0, 0}

to any other numbers, then everything works perfect, and nothing is deleted. Moreover The same snippet of code (which is copy-pasted) in different part of application (in other fragment), starts to work.


Solution

  • Is it a bug, or a feature, or did I miss something?

    This is NOT a bug, this is a feature to optimise your code.

    According to your piece of code, the second parameter is referenced by following logic as READ ONLY and its value is FIXED to be 0.

    Proguard will remove (a kind of Proguard optimisation: Remove unused parameters or Propagate constant arguments) this parameter with this KNOWN FIXED value to simplify the invocation flow.