Skip to content
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

New proguard rules broke inner classes #1787

Closed
natario1 opened this issue Dec 7, 2021 · 3 comments · Fixed by #1840
Closed

New proguard rules broke inner classes #1787

natario1 opened this issue Dec 7, 2021 · 3 comments · Fixed by #1840

Comments

@natario1
Copy link

natario1 commented Dec 7, 2021

Describe the bug
We picked serialization recently in a new project, so we're using the new proguard rules introduced with #1721 . With them, we get: "Serializer for class 'Foo' is not found.".
This does not happen with the previous rules.

To Reproduce
Foo is an inner data class:

object ApiResponses {
   @Serializable data class Foo(...)
   @Serializable data class Bar(...)
}

I can look into compiled files if needed. It's hard to debug without knowing the internals, e.g. what fields are expected to be where.

@natario1
Copy link
Author

natario1 commented Dec 7, 2021

As a side request, I have spent too much time trying to debug the issue on the wrong Foo class. It would help if the error message included the qualified class name, or at least ApiResponses.Foo instead of just Foo for inner classes.

@shanshin
Copy link
Contributor

Hi,
instead of the rule

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
    static **$* *;
}
-keepclassmembers class <1>$<3> {
    kotlinx.serialization.KSerializer serializer(...);
}

try to use

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
    static **$* *;
}
-keepclassmembers class <2>$<3> {
    kotlinx.serialization.KSerializer serializer(...);
}

@natario1
Copy link
Author

Hi,
I can try when I have time for this, likely many weeks from now. We're using the old rules successfully, and generally after several years of development, proguard directives are still incomprehensible to me, so the less I touch it, the better. I think I'm not alone in this, so it's important to have robust official rules, I appreciate your work on this.

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

Successfully merging a pull request may close this issue.

2 participants