build.gradle:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.SginConfig
}
}
I don't want Proguard to optimize, or obfuscates my code as it is causing me a lot of trouble. I only want to remove log calls and enable shrinking of unused resources.
proguard-rules.pro:
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int w(...);
public static int d(...);
public static int e(...);
}
Adding the code above to proguard-rules.pro
work only if I set getDefaultProguardFile from ('proguard-android.txt')
to ('proguard-android-optimize.txt')
But by setting it to proguard-android-optimize.txt
would enable optimization flags which I don't want in my case.
So how can I just disable logging and shrink resources without Proguard's doing any minifying or optimizations to my code?
You should be able to do this by only enabling the specific Proguard optimizations that assumenosideeffects
depends on. The two that it depends on are:
You can read more about the different optimization options here. So something like this should work:
proguard-rules.pro
-optimizations code/removal/simple,code/removal/advanced
-dontobfuscate
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int w(...);
public static int d(...);
public static int e(...);
}
build.gradle
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.SginConfig
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With