greybax / cordova-plugin-proguard

:white_square_button: Cordova Plugin for ProGuard
MIT License
51 stars 265 forks source link

Removing log and optimization doesn't work #27

Open Kohagan91 opened 3 years ago

Kohagan91 commented 3 years ago

Hi,

I'm currently working on a Cordova android app and I think your plugin can help me.

Unfortunately when I'm trying to remove logs (verbose and debug) in my release build. It seems doesn't work at all.

The issue is in build.gradle. The usage of "proguard-android.txt" instead of "proguard-android-optimze.txt".

In android sdk you can found difference between them here : proguard-android-optimze.txt proguard-android.txt

As writing in proguard-android.txt in commentary : |# Optimization is turned off by default. Dex does not like code run |# through the ProGuard optimize and preverify steps (and performs some |# of these optimizations on its own). |# Note that if you want to enable optimization, you cannot just | # include optimization flags in your own project configuration file; | # instead you will need to point to the | # "proguard-android-optimize.txt" file instead of this one from your | # project.properties file.

and in ProGuard documentation :

-assumenosideeffects : Only applicable when optimizing. In general, making assumptions can be dangerous; you can easily break the processed code. Only use this option if you know what you're doing!

So three possibilities are available for this project :

Thanks in advance for your return, I can create a PR if needed

greybax commented 3 years ago

Thank you @Kohagan91 for finding this issue and suggestions to resolve it.

So three possibilities are available for this project :

  • Remove all rules from proguard-custom.txt that are not applicable.
  • Create an argument or option of the plugin to use one or another default ProGuard configuration
  • Change in build.gradle to use in release mode "proguard-android-optimze.txt"

Actually, I would suggest going with the 2nd option, since it's more flexible and configurable. For example add --optimize param