After the project code that uses the afinal annotation is obfuscated, some view click events of some controls are invalid. afinalview
Recently, a project was launched, requiring code obfuscation. After obfuscation, click events of some controls were invalid and were later found to be afinal annotations. After checking the materials for half a day, I asked the afinal related personnel about the solution they provided. The solution was to exclude the classes whose obfuscation was annotated. This means that basically all the activities and fragment cannot be confused, this is not what I want.
Later, the decompilation code ruled out the differences between the classes to be annotated and the classes to be annotated, and found that the definition code of those controls that cannot be clicked was optimized, the reason for the optimization is that after the annotation is used, the instance of the control in the Code is not used elsewhere, so the program considers that the Code is not used and is watched out.
If you know the problem, the solution will be available. Add-dontshrink to the obfuscation configuration so that the Code is not compressed and optimized. After adding it, you will find that the obfuscation code is not much higher than the original one, if you do not mind, you can only exclude annotated classes or do not use afinal annotations.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.