Is there a way to not strip out @Preview composabl...
# compose
s
Is there a way to not strip out @Preview composables for a build that has
isMinifyEnabled = true
? Couldn’t find how to edit my proguard to make that happen My use case is that I want a different build type, that is not production, but is used to test the production experience (minified) but also be able to browse the previews rendered by Showkase
c
Copy code
-keepclasseswithmembers class * {
    @androidx.compose.ui.tooling.preview.Preview <methods>;
}
This is the right syntax if i remember correctly.
s
Doesn’t seem to work 🤔 Will have to look more into it and play with the settings
I am having a super hard time finding documentation on how to understand proguard. Isn’t there some sort of doc that explains how I would go about achieving my goal? What I want i just to keep all functions everywhere that have the preview annotation. Your example seems correct but doesn’t seem to work. Also maybe it does work but something else goes wrong, how would I know if the final result contains the function or not, is there a way to look inside the .apk or something? Sorry, super unfamiliar with all of this so I have a lot of questions and I can’t seem to find the correct documentation for it.
@Csaba Kozák suggestion looks mostly correct, but off the top of my head there's something missing (likely a
*
or something like that)
You may also need
-keepattributes *Annotation*
s
Yeah still no luck. Do you know how I could see which classes are minified and which are not after I build with minification enabled? Right now after I edit my proguard I can’t really tell if I’ve done it properly or not. Is there some sort of tool that I can use to browse the files or something like that?
e
You could look at the mapping file and see if it shows up in there
You could also try starting with a very basic keep rule that would keep everything, and work from there to make it more targeted
s
That's a great idea, I'll play around with it a bit more, maybe I'll be back in a month with more questions haha. Thank you for the help!
j
@Stylianos Gakis ProGuard Playground might be helpful for you. You can upload an APK/Jar, write some rules and interactively see which entities match those rules https://playground.proguard.com/ in general: the mapping file will show you entities that have been kept
-printmapping mapping.txt
and
-printusage usage.txt
will show you entities that shrunk.
🎉 1