kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Should the ProGuard rules include `-dontnote` rules?

Open Whathecode opened this issue 3 years ago • 0 comments

What is your use-case and why do you need this feature?

When running a build with ProGuard 7.2.1, I get a lot of notes in the output similar to:

Note: the configuration keeps the entry point 'some.serializable.Class$$serializer { some.serializable.Class deserialize(kotlinx.serialization.encoding.Decoder); }', but not the descriptor class 'kotlinx.serialization.encoding.Decoder' Note: the configuration keeps the entry point 'some.serializable.Class$$serializer { void serialize(kotlinx.serialization.encoding.Encoder,some.serializable.Class); }', but not the descriptor class 'kotlinx.serialization.encoding.Encoder'

Similar notes are added for:

  • kotlinx.serialization.encoding.CompositeEncoder
  • kotlinx.serialization.descriptors.SerialDescriptor
  • kotlinx.serialization.internal.SerializationConstructorMarker
  • kotlinx.serialization.KSerializer

Describe the solution you'd like

Should we add the following to the Android ProGuard rules? These remove all the notes for me.

-dontnote kotlinx.serialization.encoding.*
-dontnote kotlinx.serialization.internal.*
-dontnote kotlinx.serialization.KSerializer
-dontnote kotlinx.serialization.descriptors.SerialDescriptor

I'm fairly confident the internal namespace can safely be ignored. After all, these classes are supposed to be internal, so obfuscation should not matter. But, I wonder whether it doesn't make sense to simply ignore the entire kotlinx.serialization.** namespace. I don't imagine obfuscation would ever be a problem. Wouldn't the only use case to not want these classes to be obfuscated be to expose serializers in an API? E.g., you may want to keep kotlinx.serialization.KSerializer and SerialDescriptor. But, I somehow doubt that's a common use case.

P.s. In a previous PR I removed a -dontnote kotlinx.serialization.AnnotationsKt rule. I tried adding this again, but, this does not make a difference.

Whathecode avatar Apr 12 '22 14:04 Whathecode