SpringAndroid库的Android Proguard配置

时间:2014-03-25 06:26:34

标签: android proguard spring-android

我的Android应用程序使用google-play-services_lib库和另一个库项目。这个库项目反过来使用很少的第三方库(SpringAndroid)来使用json格式的Web服务。

问题是,当我尝试导出应用程序时,proguard会抛出错误并且进程停止。我的proguard配置如下。

    -verbose
    -dontskipnonpubliclibraryclassmembers
    -keepattributes *Annotation*,EnclosingMethod,Signature
    -keep class * extends java.util.ListResourceBundle {
        protected Object[][] getContents();
    }
    -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
        public static final *** NULL;
    }
    -keepnames @com.google.android.gms.common.annotation.KeepName class *
    -keepclassmembernames class * {
        @com.google.android.gms.common.annotation.KeepName *;
    }
    -keepnames class * implements android.os.Parcelable {
        public static final ** CREATOR;
    }
    -keep public class com.mypackage.** {
      public void set*(***);
      public *** get();
    }
    -keep public class com.fasterxml.jackson.** { *; }
    -dontwarn com.google.code.rome.android.repackaged.** 
    -dontwarn com.fasterxml.jackson.databind.**
    -dontwarn org.simpleframework.xml.**
    -dontwarn org.apache.commons.**
    -keep public class org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.** { *; }

由于某些原因-keep public class无法识别,我现在仍然遇到proguard错误。

            org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonFactory
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonGenerator
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonGenerator
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonFactory
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonGenerator
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonGenerator
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJackson2HttpMessageConverter: can't find referenced class com.fasterxml.jackson.core.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonFactory
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonGenerator
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.type.TypeFactory
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.type.JavaType
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonGenerator
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonFactory
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonGenerator
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.type.TypeFactory
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.map.ObjectMapper
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.type.JavaType
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.type.JavaType
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonGenerator
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.type.JavaType
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.type.JavaType
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
    org.springframework.http.converter.json.MappingJacksonHttpMessageConverter: can't find referenced class org.codehaus.jackson.JsonEncoding
           You should check if you need to specify additional program jars.
    there were 51 unresolved references to classes or interfaces.
              You may need to specify additional library jars (using '-libraryjars').
     java.io.IOException: Please correct the above warnings first.
        at proguard.Initializer.execute(Initializer.java:321)
        at proguard.ProGuard.initialize(ProGuard.java:211)
        at proguard.ProGuard.execute(ProGuard.java:86)
        at proguard.ProGuard.main(ProGuard.java:492)        

不确定我错过了什么。如果我为此配置dontwarnproguard会删除一些基本类。

1 个答案:

答案 0 :(得分:3)

尝试通过在proguard-project.txt文件中添加以下行来消除警告:

-dontwarn org.springframework.http.client.**
-dontwarn org.springframework.http.converter.feed.**
-dontwarn org.springframework.http.converter.json.**
-dontwarn org.springframework.http.converter.xml.**