Android - 使用 Joda Time 时无法使用 Proguard 导出 apk

标签 android proguard jodatime

我在我的应用程序中使用 joda-time.jar,并且在导出签名的 apk proguard 时说了类似的话(当我查看互联网时,这是一个很常见的问题):

[2014-01-07 12:44:53 - XYZ] Proguard returned with error code 1. See console
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.DateMidnight: can't find referenced class org.joda.convert.FromString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.DateTime: can't find referenced class org.joda.convert.FromString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.Days: can't find referenced class org.joda.convert.FromString
...
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.Years: can't find referenced class org.joda.convert.FromString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.Years: can't find referenced class org.joda.convert.ToString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.base.AbstractDuration: can't find referenced class org.joda.convert.ToString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.base.AbstractInstant: can't find referenced class org.joda.convert.ToString
[2014-01-07 12:44:53 - XYZ] Warning: org.joda.time.base.AbstractPeriod: can't find referenced class org.joda.convert.ToString
[2014-01-07 12:44:53 - XYZ]       You should check if you need to specify additional program jars.
[2014-01-07 12:44:53 - XYZ] Warning: there were 37 unresolved references to classes or interfaces.
[2014-01-07 12:44:53 - XYZ]          You may need to specify additional library jars (using '-libraryjars').
[2014-01-07 12:44:53 - XYZ] java.io.IOException: Please correct the above warnings first.
[2014-01-07 12:44:53 - XYZ]     at proguard.Initializer.execute(Initializer.java:321)
[2014-01-07 12:44:53 - XYZ]     at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-01-07 12:44:53 - XYZ]     at proguard.ProGuard.execute(ProGuard.java:86)
[2014-01-07 12:44:53 - XYZ]     at proguard.ProGuard.main(ProGuard.java:492)

在论坛的任何地方或这里 ( Android - Proguard didn't compile with Joda Time jar file ),他们说解决方案应该是下载 joda-convert.jar,添加到构建路径。但对我来说它只是行不通,在我这样做之后,proguard 再次说了类似的话:

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

如何解决这个问题?我花了几个小时尝试了所有方法,但就是找不到答案...非常感谢!

最佳答案

好吧,我明白了。实际上将 joda-convert.jar 添加到构建路径中是可行的,但仅适用于旧版本(1.4 及更低版本,如果您下载最新版本 - 1.5 joda-convert.jar,它不起作用)...

关于Android - 使用 Joda Time 时无法使用 Proguard 导出 apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20970872/

相关文章:

android - 如何通过 latlng 获得两点之间的距离?

javascript - 如何在 iPhone/Android 网络应用程序上制作类似 JQuery Slider 的功能?

android - setTheme() 没有完全覆盖 list 应用程序主题

java - 我在使用 Android Studio 导入 ViewPager 时遇到问题?

android - Proguard 返回错误代码 1,错误找不到引用的类 android.support.v4.app

java - 在类中使用 Joda 的 LocalDate 或 DateTime

android - 带有 proguard 问题的发布版本 - GSON

android - 启用 Pro-guard 后无法找到 [com/loopj/android/http/MySSLSocketFactory] ​​的通用父类(super class)

java - 如何正确使用Joda-Time Instant方法

hadoop - 带有ToDate内置函数的PIg- NullPointerException