| Start |
|---|
| Rules for some of the widely used Libraries Currently it contains rules for following libraries:-
|
| Remove trace logging (and other) statements at build time If you want to remove calls to certain methods, assuming they return void and have no side affects (as in, calling them doesn't change any system values, reference arguments, statics, etc.) then you can have ProGuard remove them from the output after the build is complete. For example, I find this useful in removing debug/verbose logging statements useful in debugging, but generating the strings for them is unnecessary in production. Note: If Note2: this call will remove the call to log, but will not protect you code. The Strings will actually remain in the generated apk. Read more in this post (opens new window). |
| Protecting your code from hackers Obfuscation is often considered as a magic solution for code protection, by making your code harder to understand if it ever gets de-compiled by hackers. But if you're thinking that removing the Removing all your log calls with: will indeed remove the Log call itself, but usually not the Strings you put into them. If for example inside your log call you type a common log message such as: Your de-compiled code will still have a hanging A good practice to actually remove these residuals from your code is either not put them there in the first place (Use String formatter instead, with proguard rules to remove them), or to wrap your Tip: Test how well protected your obfuscated code is by de-compiling it yourself!
|
| Enable ProGuard for your build For enabling You can also enable The above code will apply your ProGuard configurations contained in To enable you to later determine the line on which an exception occurred in a stack trace, "proguard-rules.pro" should contain following lines: To enable Proguard in Eclipse add |
| Enabling ProGuard with a custom obfuscation configuration file ProGuard allows the developer to obfuscate, shrink and optimize his code. #1 The first step of the procedure is to enable proguard on the build. This can be done by setting the 'minifyEnabled' command to true on your desired build #2 The second step is to specify which proguard files are we using for the given build This can be done by setting the 'proguardFiles' line with the proper filenames #3 The developer can then edit his proguard file with the rules he desires. That can be done by editting the file (for example 'proguard-rules-tests.pro') and adding the desired constraints. The following file serves as an example proguard file Finally, whenever the developer runs and/or generates his new .APK file, the custom proguard configurations will be applied thus fulfilling the requirements. |
Read Article
https://develop.horje.com/learn/1434/reference