Skip to content

No preview found in a minified and shrinked build (Proguard) #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomjegan opened this issue Jul 18, 2022 · 5 comments
Closed

No preview found in a minified and shrinked build (Proguard) #244

tomjegan opened this issue Jul 18, 2022 · 5 comments

Comments

@tomjegan
Copy link

With direct reference to this issue we are also experience this problem with builds where we have pro guard enabled.

As per VincentJouanne's comments we also would like to enable showkase for our internal QA builds such that design/product can inspect the components in app.

We also want to shift the annotation processing away from our dev/debug build as the build times are too high for this tool to be valuable as is unfortunately (even with ksp enabled).

Is it possible to provide a set of rules which will stop all the functions required from from converted?

Have tried StylianosGakis's suggestion but does not appear to work for us. Have also tried:

-keep class **.ShowkaseModuleCodegen { }

-keep,allowobfuscation @interface androidx.compose.ui.tooling.preview.Preview

-keep @androidx.compose.ui.tooling.preview.Preview class *
-keepclassmembers class * {
    @androidx.compose.ui.tooling.preview.Preview *;
}

-keepclassmembers class * {
    @com.airbnb.android.showkase.annotation.ShowkaseComposable <methods>;
}

But still seeing the error that there are no components.

Are we able to add in some default rules (or at least advise further in this instance) please?

@tomjegan
Copy link
Author

tomjegan commented Sep 7, 2022

Resolved. Needed to use correct name of ShowkaseRootModule implementing class. Therefore:

-keep class **.ShowkaseModuleCodegen { }

Was not correct.

Should have been.

-keep class **.ShowkaseRootCodegen { }

@tomjegan tomjegan closed this as completed Sep 7, 2022
@vinaygaba
Copy link
Collaborator

@tomjegan Thank you for the tip 🥇

@zaaaach
Copy link

zaaaach commented Oct 4, 2022

@tomjegan Is the single -keep class **.ShowkaseRootCodegen { } all that is required? I have tried that line in combination alone and in combination in my app & module level proguard rules but I am still getting the no components error.

@vinaygaba
Copy link
Collaborator

Just to summarize what's exactly needed for future reference -

You essentially need to add a proguard keep rule to make it with in release/alternate builds. The exact keep rule depends on your setup. For example, if your ShowkaseRootModule implementation looks like this -

package my.lovely.package

@ShowkaseRoot
class MyRootModule: ShowkaseRootModule

Then your proguard rule will need to be

-keep class **.MyRootModuleCodegen { }

We are essentially trying to retain the final XCodegen class that Showkase generates. The name of this generated class is of the format (_name_of_ShowkaseRootModule_implementation_)Codegen.

Hope this makes sense!

@kotasjan
Copy link

@tomjegan Thank you for your insights! Works great! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants