相关文章推荐
茫然的猴子  ·  SpringBoot枚举传参 - 简书·  1 年前    · 
一身肌肉的皮蛋  ·  403 Forbidden ...·  1 年前    · 
性感的黑框眼镜  ·  asp.net core(.net ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to prevent proguard from obfuscating interface (or abstract class) methods parameters.

Lets say I have this interface in my lib :

package com.mypackage;
public interface MyLibListener {
    void onSomething(boolean success, String message); 

And this proguard file :

-keepparameternames
-keep interface com.mypackage.MyLibListener {

Then I assemble release and I get :

package com.mypackage;
public interface MyLibListener {
    void onSomething(boolean var1, String var2);

Same thing with abstract classes or using @Keep annotations. Obfuscation option keepparameternames seems to work only for regular classes. Any idea? Thanks!

(related SO : How to not obfuscate interface methods & it's parameters using Progaurd in android? and Proguard keep interface method variable names)

@sinek I tried so many things (at the time I asked) but never found the solution :( I did not try recently sorry. Tell us if you find the way – frouo Aug 18, 2019 at 18:52

To keep all public and protected methods, which could be used by reflection:

-keepclassmembernames class * {
    public protected <methods>;

While I don't understand, why one would want to keep abstract classes, which cannot be instanced anyway, therefore it's pointless to keep & know their names. In theory, one could exclude all that is not abstract with rules which start with -keep !abstract, but that's kind of redundant.

Your proguard file may lack some -keepattributes, especially a -keepattributes Signature.

Check this example proguard configuration for a library from the proguard documentation to look for ideas.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.