Reputation: 13715
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?
Upvotes: 5
Views: 2563
Reputation: 723
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
}
}
Upvotes: 4
Reputation: 187
I think you can still try using options like -dontobfuscate
& dontshrink
in your proguard configuration file. These options will not shrink and obfuscate the code.
Upvotes: -1