2

i am using dexguard to secure my app. Recently i updated the dexgaurd version from 8.0.1 to 8.2.15. Earlier everything is working fine before the update. But with the version 8.2.15 when i apply dexguard, onCick method does not works in one of fragment SettingsFragment, for all of the other Fragments it works fine. However the code and method of implementing onClick() is same for all Fragments. But for SettingsFragment it's not working. Please help.

Here is my onClick method in SettingsFragment

View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.relSignOut:
                    mCallback.doSignOut();
                    break;
//                case R.id.relEditProfile:
//                    loadManageProfile();
//                    break;
                case R.id.btn_edit_profile:
                    loadManageProfile();
                    break;
                case R.id.relDynamicFxRate:
                    parent.startSetExchangeAlertActivity();
                    break;
            }
        }
    };

Thanks in Advance

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Yogesh Katkar
  • 369
  • 1
  • 4
  • 16

2 Answers2

1

You should exclude obfuscation of onClick methods like this:

-keepclassmembers class * {
    public void onClick (android.view.View);
}
aminography
  • 21,986
  • 13
  • 70
  • 74
  • Thanks for answer,but I did this already. It didnt help. If it obfuscating onClick() then it should have obfuscate all onCilicks(). In my case onClick() works fine with all fragments but only in SettingsFragments its not working. – Yogesh Katkar Sep 24 '18 at 06:05
  • Is it possible to you not using onClick? I mean set listener directly to the target widgets. – aminography Sep 24 '18 at 06:07
0

(Converting my comment to answer)

Please kick off the switch statement and replace it with if-else. May seem bit unscientific and illogical, but I worked for me many times.

I don't know if it's a possible bug in the compiler or in Android or not, but sometimes rejecting switch statement only doesn't help. Then I've to replace view.getId() with view.getPosition() and check by order or something like this to make it work anyway.

From T.Neidhart's comment: The reason it fails is probably due to resource optimization which remaps resource IDs. Normally these remapped resource IDs get replaced everywhere in the code, but it might go wrong in case of switch statements. You can disable resource optimization like that: -optimizations resource/compaction –

exploitr
  • 843
  • 1
  • 14
  • 27