Ошибка сборки Android: для подписи атрибута требуется атрибут InnerClasses. Проверьте директиву -keepattributes

Я сталкиваюсь с этой ошибкой при попытке создать приложение в режиме выпуска.

Error: Attribute Signature requires InnerClasses attribute. Check -keepattributes directive

Моя строчка proguard-rules.pro выглядит так:

-keepattributes Signature

какие внутренние классы имеет в виду компилятор? Что я упускаю?

Не могли бы вы включить -keepattributes InnerClasses в конфигурацию вашего proguard и проверить.

kj007 15.09.2018 14:31

@ kj007 да, это сработало, я думал, что это относится к некоторым внутренним классам сигнатур. То, как это написано, для меня немного двусмысленно

Daniele 15.09.2018 14:39

Я опубликовал свой ответ.

kj007 15.09.2018 14:45

Я также добавил возможную причину, по которой не работала Подпись.

kj007 15.09.2018 15:23
11
4
3 311
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Ответ принят как подходящий

Подпись (Java 8 или выше) работает только с Java 8 или выше и InnerClasses (Java 5 или выше), поэтому убедитесь, что ваша Android Studio использует версию Java SDK. Пожалуйста, обновите конфигурацию Proguard, указав ниже настройки

Добавьте эту строку в свой файл proguard-rules.pro:

-keepattributes InnerClasses

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.

Более подробную информацию о -keepattributes и других настройках, которые вы можете применить, см. По ссылке ниже.

Опции Proguard

Принял у меня жизнь, чтобы найти это решение

Mehrdad Shokri 18.12.2020 11:50

Ссылка: https://stuff.mit.edu/afs/sipb/project/android/sdk/android-sdk-linux/tools/proguard/docs/index.html#manual/usage.html

keepattributes [attribute_filter]

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, EnclosingMethod, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations, RuntimeVisibleParameterAnnotations, 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.

Добавить эту строку в файл proguard-rules.pro

-keepattributes InnerClasses

Более подробную информацию можно найти на сайте https://stuff.mit.edu/afs/sipb/project/android/sdk/android-sdk-linux/tools/proguard/docs/index.html#manual/usage.html

Другие вопросы по теме