Skip to content

Instantly share code, notes, and snippets.

@becejacM
becejacM / -keepclasseswithmembernames
Last active November 25, 2020 09:23
-keepclasseswithmembernames - Preserve names of classes with their native methods from being obfuscated
// Preserve names of classes with their native methods from being obfuscated
-keepclasseswithmembernames class * {
native <methods>;
}
@becejacM
becejacM / -keepclassmembers
Created November 8, 2020 12:10
-keepclassmembers - Preserve the listed members of classes that implement java.io.Serializable and which are used.
// Preserve the listed members of classes that implement java.io.Serializable and which are used.
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
@becejacM
becejacM / -keepclasseswithmembernames
Created November 8, 2020 12:04
-keepclasseswithmembernames - Preserve names for all classes if they have constructor ( mentioned as init ) with parameters( Context, AttributeSet )
// Preserve names for all classes if they have constructor ( mentioned as init ) with parameters( Context, AttributeSet )
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
@becejacM
becejacM / -keepnames
Created November 8, 2020 12:02
-keepnames - Keep names for class with name Apple and all its members
// Keep names for class with name Apple and all its members
-keepnames class com.company.appname.Apple { *; }
@becejacM
becejacM / -keepclasseswithmembers
Last active November 8, 2020 12:01
-keepclasseswithmembers - Preserve all classes if they have constructor ( mentioned as init ) with parameters( Context, AttributeSet )
// Preserve all classes if they have constructor ( mentioned as init ) with parameters( Context, AttributeSet )
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
@becejacM
becejacM / Prevent all classes from package model from being obfuscated
Created November 8, 2020 10:58
The following code will prevent all classes from package model from being obfuscated
-keep class com.companyName.appName.model.** { *; }
@becejacM
becejacM / Determine the exception line
Created November 8, 2020 10:57
Add the following code to proguard-rules.pro to enable you to later determine the line on which an exception occurred in a stack
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
@becejacM
becejacM / -keep
Last active November 8, 2020 12:01
-keep rule - Preserve class with name Apple and all its members
// Preserve class with name Apple and all its members
-keep class com.company.appname.Apple { *; }
@becejacM
becejacM / The full report of all the rules that R8 applies
Created November 8, 2020 10:53
The full report of all the rules that R8 applies (You can specify any path and filename)
// You can specify any path and filename.
-printconfiguration ~/tmp/full-r8-config.txt
@becejacM
becejacM / build.gradle(Module:app) with Consumer rules
Created November 8, 2020 10:51
build.gradle(Module:app) with R8 enabled for release mode and disabled for debug and with Consumer-rules file, which will be included in library's build configuration
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'consumer-proguard-file.pro
}
}