Member-only story
ProGuard, R8 and Reverse Engineering Protection
ProGuard is a tool used in Android development to optimize and obfuscate code. It’s an optimization tool that can remove unused code and shrink the size of the application. It also helps to make the code difficult to understand or reverse-engineer by renaming classes, methods, and fields, which is called obfuscation.
ProGuard comes with a set of default rules that are applied to the code during the build process. However, developers can also define their own rules for specific classes, methods, or fields. The rules are defined in a ProGuard configuration file, usually named proguard-rules.pro, which is located in the app module of the Android project.
Here are some examples of ProGuard rules:
- Keep a specific class:
-keep class com.example.MyClass { *; }This rule ensures that the class com.example.MyClass is not removed during the optimization process.
2. Keep a specific method:
-keepclassmembers class com.example.MyClass {
public void myMethod(java.lang.String);
}This rule ensures that the method myMethod in the class com.example.MyClass is not removed during the optimization process.