How to not obfuscate class names but get the right simplename anyway?

1.8k views Asked by At

I have over 20 Fragments which extends from MyFragment e.g.:

  • LoginFragment extends MyFragment
  • UploadFragment extends MyFragment
  • CameraFragment extends MyFragment
  • etc..

and MyFragment in turn extends from Fragment . So in my Android app, and whenever I inflate one of them, I call in my abstrac t class a showFragment(MyFragment f) where I fire the Adjust event,

AdjustEvent event = new AdjustEvent(EVENT_LOAD_FRAGMENT);
// Add callback parameters to this parameter.
event.addCallbackParameter("LoadFragment", 
f.getClass().getSimpleName());
Adjust.trackEvent(event);

so that I can measure what fragment is how often used as kay value pair. So far so good, and during debug phase it works nice.

As you can imagine now, the getClass().getSimpleName() is being obfuscated in the produtction environment. I do not want to touch all the 20 Fragments and would be totally fine if the classes get obfuscated. But I still would like to get the class' valid getSimpleName() String..

How can I get a classes valid getSimpleName() after it was obfuscated?

2

There are 2 answers

0
Tranquillo On BEST ANSWER

I used

-keepnames class  * extends com.you.package.name.MyFragment

unpacked the aar and classes.jar, and checked the build forlder for seeds.txt and mapping.txt to see the obfuscation

4
shizhen On

add below to your proguard configuration file.

-keep,allowobfuscation class  * extends com.you.package.name.MyFragment