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).

Sign up to request clarification or add additional context in comments.

4 Comments

That's it! I didn't know it's called method inlining before. Thank you very much for your answer!
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?
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.
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 ;)
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 Comment

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?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.