xcesco
xcesco

Reputation: 4838

How to keep field's annotation with proguard at runtime

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.

Upvotes: 0

Views: 721

Answers (1)

Dylan
Dylan

Reputation: 1395

use:

-keepattributes *Annotation*

Upvotes: 2

Related Questions