Proguard没有保留GSON的JsonScope字段和方法

时间:2014-08-19 04:50:27

标签: android gson proguard retrofit

我正在使用Retrofit,在构建版本时,我看到了以下内容:

Warning:com.google.gson.stream.JsonReader$2: can't find referenced method 'com.google.gson.stream.JsonScope[] values()' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope EMPTY_DOCUMENT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced method 'int ordinal()' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope EMPTY_ARRAY' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope NONEMPTY_ARRAY' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope EMPTY_OBJECT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope DANGLING_NAME' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope NONEMPTY_OBJECT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope NONEMPTY_DOCUMENT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonReader$2: can't find referenced field 'com.google.gson.stream.JsonScope CLOSED' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced method 'com.google.gson.stream.JsonScope[] values()' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced field 'com.google.gson.stream.JsonScope NONEMPTY_DOCUMENT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced method 'int ordinal()' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced field 'com.google.gson.stream.JsonScope EMPTY_DOCUMENT' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced field 'com.google.gson.stream.JsonScope EMPTY_ARRAY' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced field 'com.google.gson.stream.JsonScope NONEMPTY_ARRAY' in program class com.google.gson.stream.JsonScope
Warning:com.google.gson.stream.JsonWriter$1: can't find referenced field 'com.google.gson.stream.JsonScope DANGLING_NAME' in program class com.google.gson.stream.JsonScope
Warning:there were 17 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

我的proguard-project.txt如下:

-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;
}

-dontwarn org.mockito.**
-dontwarn sun.reflect.**
-dontwarn android.test.**

-keepattributes Signature

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

-keepclassmembers class ** {
    @com.squareup.otto.Subscribe public *;
    @com.squareup.otto.Produce public *;
}

-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}

-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

-dontwarn rx.**
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep interface com.google.gson.stream.** { *; }
-keep class com.google.protobuf.** { *; }

-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Package path for GSON models
-keep class com.threadflip.android.api.** { *; }
-keep interface com.threadflip.android.api.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }

所以,似乎proguard应该保持com.google.gson.stream.JsonScope,但显然没有发生,我不明白为什么。

任何帮助表示赞赏!

0 个答案:

没有答案