Proguard issue "Warning:Ignoring InnerClasses attribute for an anonymous inner class"

Try adding

-keepattributes InnerClasses
-dontoptimize

to the ProGuard config. That should fix the problem.

It's probable that incompatible optimizations are applied (that probably causes the last line of the error log).

If you want to allow optimizations, it's necessary to fine tune optimizations config with

-optimizations optimization_filter 

option in ProGuard config.


Adding these lines to proguard-rules.pro file fixed my issue.

-keepattributes EnclosingMethod
-keepattributes InnerClasses

I suggest -dontwarn InnerClasses


I've noticed that often the cause for this problem is when proguard-android.txt file is not referenced in the project, as it contains the correct configuration to avoid this issue:

# Preserve some attributes that may be required for reflection.
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod

Solution

Make sure to add this file to your project, along with your own ProGuard configuration files, for example:

release {
    minifyEnabled true
    setProguardFiles([getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'])
}

The file is contained in the SDK so your gradle build will pick it up automatically, you don't need to copy it to your project.