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

Proguard renaming of TimeUnit classes can lead to MissingResourceException: Can't find resource for bundle org.ocpsoft.prettytime.i18n.Resources, key ePattern #222

Open
kevinslashslash opened this issue Jul 24, 2021 · 3 comments

Comments

@kevinslashslash
Copy link

The bundled proguard rules only keep org.ocpsoft.prettytime.i18n but some ResourceBundle classes rely on TimeUnit.getClass().getSimpleName() which are in org.ocpsoft.prettytime.units and thus allowed to be renamed by proguard.

For example

return new DeTimeFormat(this, t, t.getClass().getSimpleName());

Solutions I can think of are
Refactor code to not use TimeUnit.getClass().getSimpleName(), it looks like ResourcesTimeUnit.getResourceKeyPrefix() is appropriate but it's not on TimeUnit directly
Update proguard rules to keepnames for org.ocpsoft.prettytime.units, this is easiest to do but feels less than idea. It also slightly feels like it's covering up a deeper problem.

@kevinslashslash
Copy link
Author

Relevant stack trace

java.util.MissingResourceException: Can't find resource for bundle org.ocpsoft.prettytime.i18n.Resources, key ePattern
        at java.util.ResourceBundle.getObject(ResourceBundle.java:445)
        at java.util.ResourceBundle.getObject(ResourceBundle.java:439)
        at java.util.ResourceBundle.getString(ResourceBundle.java:402)
        at org.ocpsoft.prettytime.i18n.Resources_de$DeTimeFormat.<init>(Resources_de:141)
        at org.ocpsoft.prettytime.i18n.Resources_de.getFormatFor(Resources_de:133)
        at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(ResourcesTimeFormat:52)
        at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(ResourcesTimeFormat:15)
        at org.ocpsoft.prettytime.PrettyTime.registerUnit(PrettyTime:1473)
        at org.ocpsoft.prettytime.PrettyTime.addUnit(PrettyTime:1613)
        at org.ocpsoft.prettytime.PrettyTime.initTimeUnits(PrettyTime:1597)
        at org.ocpsoft.prettytime.PrettyTime.<init>(PrettyTime:98)
        at org.ocpsoft.prettytime.PrettyTime.<init>(PrettyTime:86)
        ```

@Mrjpjay
Copy link

Mrjpjay commented Apr 19, 2022

Same issue

@lincolnthree
Copy link
Member

Happy to accept a PR for these issues. Thanks!

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

3 participants