Using joda-time-android with proguard

I am trying to use joda-time-android in my application and also use proguard. The problem is that when I try to get LocalDate as from an intent, like this:

LocalDate date = (LocalDate) data.getSerializableExtra("dueDate");

I get this error:

Process: org.mpardalos.homeworkmanager, PID: 7509
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { (has extras) }} to activity {org.mpardalos.homeworkmanager/org.mpardalos.homeworkmanager.TaskList}: java.lang.NullPointerException
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3389)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)
            at android.app.ActivityThread.access$1300(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at org.joda.time.LocalDate.isSupported(LocalDate.java:577)
            at org.joda.time.format.DateTimeFormatterBuilder$PaddedNumber.printTo(DateTimeFormatterBuilder.java:1434)
            at org.joda.time.format.DateTimeFormatterBuilder$Composite.printTo(DateTimeFormatterBuilder.java:2446)
            at org.joda.time.format.DateTimeFormatter.print(DateTimeFormatter.java:663)
            at org.joda.time.base.AbstractPartial.toString(AbstractPartial.java:412)
            at org.mpardalos.homeworkmanager.TaskList.onActivityResult(TaskList.java:91)
            at android.app.Activity.dispatchActivityResult(Activity.java:5423)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3385)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3432)
            at android.app.ActivityThread.access$1300(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
            at dalvik.system.NativeStart.main(Native Method)

and the debugger says about this variable:

Method threw 'java.lang.NullPointerException' exception.

However, the problem disappears as soon as I minifyEnabledremove the gradle from the assembly file.

The only workaround I found was to disable proguard, since the application is relatively small (2 MB without proguard - 0.9 MB with it), but I plan to add a lot more functionality, so I will need this in the future.

Can someone point me to a solution to the problem?

TL DR joda-time-android does not work when proguard is turned on

+4
1

v2.9.9 joda-time-android, proguard. , proguard :

consumerProguardFiles 'proguard-rules.txt'

build.gradle.

:
https://github.com/dlew/joda-time-android/blob/master/library/build.gradle

+1

Source: https://habr.com/ru/post/1570481/


All Articles