gpt4 book ai didi

android - 在 android 中运行 proguard 时 Jackson.jar 出错

转载 作者:太空狗 更新时间:2023-10-29 16:05:16 24 4
gpt4 key购买 nike

我有一个使用 jackson-all-1.7.2.jar 的 android 项目。

当我使用这个 proguard.cfg 文件运行混淆器时:

-keep class com.actionbarsherlock.** {*;}
-keep class org.holoeverywhere.** {*;}

-libraryjars /libs/jackson-all-1.7.2.jar

我遇到了这个异常:

[2013-06-15 06:06:04 - ArrowAndroid] Proguard returned with error code 1. See console
[2013-06-15 06:06:04 - ArrowAndroid] Note: there were 600 duplicate class definitions.
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find superclass or interface javax.ws.rs.ext.MessageBodyReader
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find superclass or interface javax.ws.rs.ext.MessageBodyWriter
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper: can't find superclass or interface javax.ws.rs.ext.ExceptionMapper
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JsonParseExceptionMapper: can't find superclass or interface javax.ws.rs.ext.ExceptionMapper
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.xc.DataHandlerJsonDeserializer$1: can't find superclass or interface javax.activation.DataSource
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider: can't find referenced class javax.ws.rs.ext.Provider
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider: can't find referenced class javax.ws.rs.Consumes
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider: can't find referenced class javax.ws.rs.Produces
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.core.MediaType
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.ext.Providers
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.ext.ContextResolver
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.core.StreamingOutput
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.core.Response
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.ext.MessageBodyReader
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.ext.MessageBodyWriter
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.core.MediaType
[2013-06-15 06:06:04 - ArrowAndroid] Warning: org.codehaus.jackson.jaxrs.JacksonJsonProvider: can't find referenced class javax.ws.rs.ext.Providers
.....
.....
.....
[2013-06-15 06:06:04 - ArrowAndroid] You should check if you need to specify additional program jars.
[2013-06-15 06:06:04 - ArrowAndroid] Warning: there were 387 unresolved references to classes or interfaces.
[2013-06-15 06:06:04 - ArrowAndroid] You may need to specify additional library jars (using '-libraryjars').
[2013-06-15 06:06:04 - ArrowAndroid] java.io.IOException: Please correct the above warnings first.
[2013-06-15 06:06:04 - ArrowAndroid] at proguard.Initializer.execute(Initializer.java:321)
[2013-06-15 06:06:04 - ArrowAndroid] at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-06-15 06:06:04 - ArrowAndroid] at proguard.ProGuard.execute(ProGuard.java:86)
[2013-06-15 06:06:04 - ArrowAndroid] at proguard.ProGuard.main(ProGuard.java:492)

请注意,应用程序在没有 proguard 的情况下运行完美。

当我在 proguard.cfg 中添加以下行时-dontwarn org.codehaus.jackson

应用崩溃报告此异常:

Caused by: java.lang.ExceptionInInitializerError
at org.codehaus.jackson.map.ObjectMapper.<clinit>(Unknown Source)
... 15 more
Caused by: java.lang.NoSuchFieldError: PUBLIC_ONLY
at java.lang.Class.getDeclaredAnnotation(Native Method)
at java.lang.Class.getAnnotation(Class.java:260)
at org.codehaus.jackson.map.introspect.VisibilityChecker$Std.<clinit>(Unknown Source)
... 16 more

最佳答案

文件 jackson-all-1.7.2.jar 已经在您的 libs 目录中,因此 Android Ant/Eclipse 构建将自动获取它。您不应该使用 -libraryjars 再次阅读它,因为那样您会收到这些关于重复项的警告。

Jackson 正在使用反射来查找一些注释。 ProGuard 无法自动推断出这一点,它最终会删除相关的、看似未使用的字段。此配置应保留它们:

-keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *;
}

关于android - 在 android 中运行 proguard 时 Jackson.jar 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17120112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com