0

Which ProGuard/R8 rules to use?

Currently only Activites aren't renamed

enter image description here

I need to keep names of Fragment for screens logging as well but the code itself in fragments should be obfuscated

user924
  • 8,146
  • 7
  • 57
  • 139

3 Answers3

2

You can say proguard to keep names for all classes that extend androidx.fragment.app.Fragment (or another base Fragment class that you use)

-keepnames class * extends androidx.fragment.app.Fragment
sergpetrov
  • 1,506
  • 1
  • 11
  • 20
0

I would highly suggest you to read this documentation: https://www.guardsquare.com/manual/configuration/usage#keepoptions

Also use the -keepnames option in your proguard.cfg

I'll give you an example:

-keepnames class_specification

You could also use this in order to avoid obuscation of any class name:

-keepnames class ** { *; }
Jonathan
  • 203
  • 3
  • 15
0

Simply add proguardrules to keep your directory which contains all the fragments so write below proguardrules:

-keep public class com.your_app_name.app.view.fragments.** {*;}

Ex: My package name is com.tdscalculator.app and all my fragments are inside com -> tdscalculator -> app -> view -> fragments so for this example I have written above proguardrule so modify this rule accordingly.

If you want to keep fragments of different directories then mention all fragments using below proguardrules:

-keepnames class  com.your_app_name.app.view.fragments.HomeFragment{}
halfer
  • 19,824
  • 17
  • 99
  • 186
Jaydeep parmar
  • 561
  • 2
  • 15