编译时出现Android Proguard错误

时间:2014-07-11 23:44:32

标签: android proguard

我第一次使用proguard,当我编译应用程序时,我收到了以下错误堆栈:

Note: there were 1 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning:org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning:org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableDateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableInstant
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateTimeDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateTimeDeserializer: can't find referenced class org.joda.time.DateTimeZone
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateTimeDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$DateTimeDeserializer: can't find referenced class org.joda.time.ReadableInstant
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$JodaDeserializer: can't find referenced class org.joda.time.format.DateTimeFormatter
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$JodaDeserializer: can't find referenced class org.joda.time.format.ISODateTimeFormat
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$JodaDeserializer: can't find referenced class org.joda.time.format.DateTimeFormatter
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$JodaDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateDeserializer: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateDeserializer: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateDeserializer: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateTimeDeserializer: can't find referenced class org.joda.time.LocalDateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateTimeDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateTimeDeserializer: can't find referenced class org.joda.time.LocalDateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateTimeDeserializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaDeserializers$LocalDateTimeDeserializer: can't find referenced class org.joda.time.LocalDateTime
Warning:org.codehaus.jackson.map.ext.JodaSerializers: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaSerializers: can't find referenced class org.joda.time.LocalDateTime
Warning:org.codehaus.jackson.map.ext.JodaSerializers: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaSerializers: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaSerializers$DateMidnightSerializer: can't find referenced class org.joda.time.DateMidnight$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$DateMidnightSerializer: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaSerializers$DateMidnightSerializer: can't find referenced class org.joda.time.DateMidnight$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$DateMidnightSerializer: can't find referenced class org.joda.time.DateMidnight
Warning:org.codehaus.jackson.map.ext.JodaSerializers$DateTimeSerializer: can't find referenced class org.joda.time.DateTime
Warning:org.codehaus.jackson.map.ext.JodaSerializers$JodaSerializer: can't find referenced class org.joda.time.format.DateTimeFormatter
Warning:org.codehaus.jackson.map.ext.JodaSerializers$JodaSerializer: can't find referenced class org.joda.time.format.ISODateTimeFormat
Warning:org.codehaus.jackson.map.ext.JodaSerializers$JodaSerializer: can't find referenced class org.joda.time.format.DateTimeFormatter
Warning:org.codehaus.jackson.map.ext.JodaSerializers$JodaSerializer: can't find referenced class org.joda.time.ReadablePartial
Warning:org.codehaus.jackson.map.ext.JodaSerializers$JodaSerializer: can't find referenced class org.joda.time.ReadableInstant
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateSerializer: can't find referenced class org.joda.time.LocalDate$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateSerializer: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateSerializer: can't find referenced class org.joda.time.LocalDate$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateSerializer: can't find referenced class org.joda.time.LocalDate
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateTimeSerializer: can't find referenced class org.joda.time.LocalDateTime$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateTimeSerializer: can't find referenced class org.joda.time.LocalDateTime
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateTimeSerializer: can't find referenced class org.joda.time.LocalDateTime$Property
Warning:org.codehaus.jackson.map.ext.JodaSerializers$LocalDateTimeSerializer: can't find referenced class org.joda.time.LocalDateTime
Warning:there were 99 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
:app:proguardDebug FAILED

我尝试了对proguard-rules.txt的基本更改,并对该文件中的所有内容进行了注释并获得了相同的结果,因此该内容(或缺少内容)似乎与此无关错误被抛出。

正如你所看到的,没有任何东西指向究竟是什么重复。此外,有关复制的消息下面的警告行引用了我在我的应用程序中不使用的包。

我已尝试搜索此问题并尝试添加一些行,例如

-keep class android.support.v4.** { *; }

有人建议,但没有做到这一点。

以下是我的应用程序的build.gradle文件中的某个内容:

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

我的应用程序的根文件夹中有一个文件proguard-rules.txt(与我的build.gradle文件相同的目录),但我没有proguard-android.txt文件,或者其他地方我可以找到那件事。这可能是一个原因吗?

有什么想法吗?谢谢!

3 个答案:

答案 0 :(得分:1)

你实际上没有任何错误,根据log的说法,这些是警告

If your code works fine without the missing classes, you can suppress
     the warnings with '-dontwarn' options.
可以使用 ProGuard配置中的以下行抑制

-dontwarn org.codehaus.jackson.map.ext.**

答案 1 :(得分:1)

添加您的PROGuard文件:

-dontwarn org.joda.convert.**
-dontwarn org.codehaus.jackson.map.ext.**
-keep class org.w3c.dom.bootstrap.** { *; }
-keep class org.joda.time.** { *; }

答案 2 :(得分:0)

尝试将以下内容添加到您的proguard配置中:

-keep class org.w3c.dom.bootstrap.** { *; }
-keep class org.joda.time.** { *; }