1

I am currently creating a library for private use which provides an Annotation (lets call it @Something) which can be used on Properties of a data class. I created the annotation like so:

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.PROPERTY)
annotation class Something

It will be used like this

data class SomeDataClass (val param1: String, @Something val param2: String, val param3: String)

I then want to be able to access the following things on the class that contains properties with this annotation:

  • memberFunctions (to get the copy constructor)
  • parameters of the copy constructor
  • memberProperties
  • property annotations
  • property name
  • List item

Now everything works properly until I minify my library with ProGuard. As I understand it, I need to describe my ProGuard rules in consumer-rules.pro. But what exactly do I need to add here? I want every data class in the application that uses my library that has a property annotated with @Something to be kept so I can read the things above from it.

sunilson
  • 1,449
  • 15
  • 31
  • Have you tried using [`@androidx.annotation.Keep`](https://developer.android.com/reference/androidx/annotation/Keep) before writing your own annotation? – Pawel Apr 18 '20 at 18:29
  • try this link https://stackoverflow.com/questions/47515093/keep-specific-annotation-with-proguard – unzila Apr 18 '20 at 18:33
  • The annotation I created in my library should be used outside of the library, so I need to make sure every class outside of the library that uses it is kept by ProGuard. I can't add @Keep to classes I don't own, right? And doesn't `-keep class Annotation1{*;}` just keep the annotation but not all the other stuff I want to keep? – sunilson Apr 18 '20 at 18:52

0 Answers0