2

I'm considering using Proguard as my app comes closer to production to make it lighter.

On Android, there's the 65K method limit in addition to low storage devices. I know that Proguard removes unused methods, but does it remove methods which are used only in one place? I mean, I'm writing some methods just to make the code cleaner, but it would save a method call (one of the most expensive operation with return for the CPU and RAM, I studied microcode) and a method in the 65K max count as well as some bytes in the final package.

Does Proguard detect such cases and remove methods? Do I have to configure it myself? What about stacktrace deobfuscation if so?

2 Answers 2

3

It does not remove them since the code is used.

If you have the method/inlining/unique optimization enabled, it will inline such methods: the method call is removed and the method code is inserted in the place where the method call was.

What about stacktrace deobfuscation if so?

If there's an exception in the inlined method, it will show up in the stacktrace at the method call site (where the call was removed).

4
  • That's it! I didn't know it's called method inlining before. Thank you very much for your answer!
    – Louis CAD
    Nov 4, 2015 at 10:59
  • I have a class with one shot methods, but these static methods are used in another class the only time they are used. Do you know if Proguard would still remove the class after inlining the methods?
    – Louis CAD
    Nov 4, 2015 at 15:01
  • 1
    Make an experiment to find out. Build a proguarded package and use e.g. apktool to reverse engineer it and study what bytecode is left and what is not.
    – laalto
    Nov 4, 2015 at 15:09
  • Reading your comment made me realize than I can check if the class is still there after reverse engineering. However, I would use Show Java instead of apktool to see java instead of smali ;)
    – Louis CAD
    Nov 4, 2015 at 15:12
0

If used proguard will not remove the method.

And, If you already know one such method, why don't you just build an apk with proguard enabled and test out the functionality in the app which makes the method call and check for yourself?

1
  • laalto already found the answer, but I'm curious... how do you test if a method has been inlined, or if any other optimization has been done by Proguard?
    – Louis CAD
    Nov 4, 2015 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.