I’m facing this error when trying to build the app in release mode.
Error: Attribute Signature requires InnerClasses attribute. Check -keepattributes directive
proguard-rules.pro line looks like this:
what InnerClasses is the compiler referring to? What am I omitting?
Signature (Java 8 or higher) works only Java 8 or higher and InnerClasses (Java 5 or higher) so check your Android Studio is using Java SDK version.
Please update your Proguard config with below settings
Add this line to your
InnerClasses (Java 5 or higher)
Specifies the relationship between a class and its inner classes and
outer classes. Other than this and the naming convention with a ‘$’
separator between the names of inner classes and outer classes, inner
classes are just like ordinary classes. Compilers may need this
information to find classes referenced in a compiled library. Code may
access this information by reflection, for instance to derive the
simple name of the class.
Signature (Java 8 or higher)
Specifies the generic signature of the class, field, or method.
Compilers may need this information to properly compile classes that
use generic types from compiled libraries. Code may access this
signature by reflection.
More details about
-keepattributes and more settings you can apply, please see below link.
Specifies any optional attributes to be preserved. The attributes can
be specified with one or more -keepattributes directives. The optional
filter is a comma-separated list of attribute names. Attribute names
can contain ?, *, and ** wildcards, and they can be preceded by the !
negator. Typical optional attributes are Exceptions, Signature,
Deprecated, SourceFile, SourceDir, LineNumberTable,
LocalVariableTable, LocalVariableTypeTable, Synthetic,
RuntimeInvisibleParameterAnnotations, and AnnotationDefault. The
InnerClasses attribute name can be specified as well, referring to the
source name part of this attribute. For example, you should at least
keep the Exceptions, InnerClasses, and Signature attributes when
processing a library. You should also keep the SourceFile and
LineNumberTable attributes for producing useful obfuscated stack
traces. Finally, you may want to keep annotations if your code depends
on them. Only applicable when obfuscating.
Add This Line in proguard-rules.pro File