How to keep field's annotation with proguard at runtime

621 views Asked by At

I'm working on an Android App. The application works like a charm until I tried to obfuscate the code with Proguard.

import com.mobsandgeeks.saripaar.annotation.NotEmpty;

public class TaccuinoFragment extends Fragment {

    private TaccuinoViewModel mViewModel;

    @NotEmpty(messageResId = R.string.error_campo_obbligatorio)
    TextInputLayout titoloLayout;

}

The gradle configuration:

release {
  signingConfig signingConfigs.config
  zipAlignEnabled true
  minifyEnabled true
  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), System.getenv("GRADLE_PROGUARD_CONFIG_FILE"), 'proguard-rules.pro'
}

I tried the following Proguard's configuration:

-keepclasseswithmembernames class * {  @com.mobsandgeeks.saripaar.annotation.** <fields>;}

How can I keep the NotEmpty annotation at runtime? Thank you in advance.

1

There are 1 answers

2
Dylan On BEST ANSWER

use:

-keepattributes *Annotation*