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

Sending ZonedDateTime through Intent loses tz info if Proguard is enabled #44

Closed
reisub opened this issue Dec 20, 2016 · 10 comments · Fixed by #108
Closed

Sending ZonedDateTime through Intent loses tz info if Proguard is enabled #44

reisub opened this issue Dec 20, 2016 · 10 comments · Fixed by #108

Comments

@reisub
Copy link

reisub commented Dec 20, 2016

Here is a minimal project to reproduce the issue:
https://github.com/reisub/ZonedDateTimeProguardBug

After fiddling with proguard for the last hour and half - I only know that this will definitely fix it:

-keep class org.threeten.bp.** { *; }

.. but that keeps the whole library from being obfuscated. Proguard is pain.

@JakeWharton
Copy link
Owner

We can enable ProGuard on the sample and round-trip through a Parcel to ensure that rules (which we can embed in the library) retain the necessary info. I don't have time to work on this right now, unfortunately.

@dbarwacz
Copy link

Is this still an issue? We are adding this library and would probably need it fixed so I can create PR if that's still an open and broken.

@marcelpinto
Copy link

We are getting crashes in production version when parcelling a class that uses LocalDateTime

Fatal Exception: java.lang.ClassCastException: org.threeten.bp.n cannot be cast to org.threeten.bp.LocalDateTime at com.mypackage.MyTimeClass$NotNow$Creator.createFromParcel(Unknown Source:11)

Adding the rule @reisub mentions works, although is quite drastic to keep all the library. I tried to add rule by rule depending on the classes that LocalDateTime uses but seems not to work.

@JakeWharton
Copy link
Owner

JakeWharton commented Jan 9, 2019 via email

@marcelpinto
Copy link

That overly keepy rule isn't needed, but you might need to keep the names of the types in the library if they're Serializable?

On Tue, Jan 8, 2019, 9:33 PM Marcel Pintó Biescas @.*** wrote: We are getting crashes in production version when parcelling a class that uses LocalDateTime Fatal Exception: java.lang.ClassCastException: org.threeten.bp.n cannot be cast to org.threeten.bp.LocalDateTime at com.mypackage.MyTimeClass$NotNow$Creator.createFromParcel(Unknown Source:11) Adding the rule @reisub https://github.com/reisub mentions works, although is quite drastic to keep all the library. I tried to add rule by rule depending on the classes that LocalDateTime uses but seems not to work. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#44 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEf1_CdbAQjJevnVbIxVW_tKzulI8ks5vBVTdgaJpZM4LR1kA .

I tried keeping all names from the library but still does not work. Maybe I am missing sth...

@JakeWharton
Copy link
Owner

JakeWharton commented Jan 9, 2019 via email

@drewhamilton
Copy link
Contributor

Looked into this and found that ProGuard's website has an example for keeping all methods related to processing Serializables:

-keepclassmembers class * implements java.io.Serializable {
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

Applying this to @reisub's example repo appears to solve the issue. Is this sufficiently... not overly keepy?

@JakeWharton
Copy link
Owner

JakeWharton commented Mar 13, 2019 via email

@drewhamilton
Copy link
Contributor

Cool, I'll try to put up a PR with that + related tests soon.

@drewhamilton
Copy link
Contributor

Bump: This is fixed by #102.

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