This is strange as there is a rule in DateUtils.proguard to keep b4a.example.dateutils._period. I'm unable to reproduce this.
Do you get this error with a new project with DateUtils selected?
1. The Typo/Format Discrepancy (._period vs $_period)
Notice the syntax difference:
What you typed / what was tried: b4a.example.dateutils._period (using a dot .)
What Java actually uses for inner types: b4a.example.dateutils$_period (using a dollar sign $)
In compiled Java bytecode, an inner class or custom structure inside a module uses a $ sign, not a dot. If a ProGuard keep rule is written with ._period, R8 won't match the inner type and will strip it out anyway.
2. The Package Name Mismatch
When a developer wrote:
B4X:
AddProguardText(-keep class b4a.example.dateutils$_period { *; })
that rule only works if the project's Package Name in Build Configurations is literally left as b4a.example.
If the developer renamed their package to something else (e.g. com.mycompany.app), then the compiled Java class becomes com.mycompany.app.dateutils$_period. Hardcoding b4a.example in the rule means R8 ignores it and the crash still happens.
3. Another Forum Member Suggested xxx
Another forum user posted AddProguardText(-keep class xxx.dateutils.** { *; }) assuming xxx would act like a wildcard, but ProGuard treated xxx as a literal package named "xxx". That's why the original poster kept reporting: "still same exception".
The Clean Solution That Ended Up Working
Peter Simpson resolved the thread by providing the universal wildcard rule:
B4X:
AddProguardText(-keep class **.dateutils$_period { *; })
Why this works for everyone:
The ** wildcard: Matches any package name (b4a.example, com.company.app, etc.).
The $_period symbol: Uses the correct Java dollar-sign syntax ($) for inner custom types rather than a dot (.).
Example.
If your package name in B4A is my.project, then the compiled Java class path becomes:
- my.project.dateutils (for the DateUtils code module)
- my.project.dateutils$_period (for the Period structure inside it)