Java – Joda time and ProGuard errors when exporting .apk

Joda time and ProGuard errors when exporting .apk… here is a solution to the problem.

Joda time and ProGuard errors when exporting .apk

In Eclipse, when I export .apk and enable proguard, I get the following build error:

[2014-07-10 04:13:30 - VirginMobile] Proguard returned with error code 1. See console
[2014-07-10 04:13:30 - VirginMobile] Warning: org.joda.convert.JDKStringConverter$9: can't find referenced class javax.xml.bind.DatatypeConverter
[2014-07-10 04:13:30 - VirginMobile] Warning: org.joda.convert.JDKStringConverter$9: can't find referenced class javax.xml.bind.DatatypeConverter
[2014-07-10 04:13:30 - VirginMobile] Warning: org.joda.convert.JDKStringConverter$9: can't find referenced class javax.xml.bind.DatatypeConverter
[2014-07-10 04:13:30 - VirginMobile]       You should check if you need to specify additional program jars.
[2014-07-10 04:13:30 - VirginMobile] Warning: there were 3 unresolved references to classes or interfaces.
[2014-07-10 04:13:30 - VirginMobile]          You may need to specify additional library jars (using '-libraryjars').
[2014-07-10 04:13:30 - VirginMobile] java.io.IOException: Please correct the above warnings first.
[2014-07-10 04:13:30 - VirginMobile]    at proguard. Initializer.execute(Initializer.java:321)
[2014-07-10 04:13:30 - VirginMobile]    at proguard. ProGuard.initialize(ProGuard.java:211)
[2014-07-10 04:13:30 - VirginMobile]    at proguard. ProGuard.execute(ProGuard.java:86)
[2014-07-10 04:13:30 - VirginMobile]    at proguard. ProGuard.main(ProGuard.java:492)

The solution could not be found in any other thread.

I included joda-time-2.3.jar and joda-convert-1.6.jar (which eliminated all but three errors). Does anyone know how to fix this?

Thank you so much.

Solution

The Joda class org.joda.convert.JDKStringConverter uses the Java API class javax.xml.bind.DatatypeConverter, which is not available in the Android API

If you don’t actually use the JDKStringConverter class, Joda may still run on Android, but ProGuard tries to make sure all dependencies are met.

You can try using the “-dontwarn javax.xml.bind.DatatypeConverter” option to tell ProGuard to ignore missing dependencies.

Related Problems and Solutions