在我的项目上运行proguard后一切都很顺利,但我遇到了问题。我在规则中使用gson规范,但我仍然遇到这种错误。通常这段代码效果很好。嗯,任何人都有任何想法吗?
com.google.gson.p: java.lang.NumberFormatException: Invalid double: "1271.jpg"
at com.google.gson.b.a.q$29.a(Unknown Source)
at com.google.gson.b.a.q$29.b(Unknown Source)
at com.google.gson.b.a.k$1.a(Unknown Source)
at com.google.gson.b.a.l.b(Unknown Source)
at com.google.gson.d.a(Unknown Source)
at com.google.gson.d.a(Unknown Source)
at com.google.gson.d.a(Unknown Source)
at pl.app.model.f.a(Unknown Source)
at pl.app.fragment.g.a.a(Unknown Source)
at android.support.v4.app.Fragment.i(Unknown Source)
at android.support.v4.app.m.a(Unknown Source)
at android.support.v4.app.m.b(Unknown Source)
at android.support.v4.app.Fragment.f(Unknown Source)
at android.support.v4.app.o.b(Unknown Source)
at android.support.v4.view.ViewPager.a(Unknown Source)
at android.support.v4.view.ViewPager.c(Unknown Source)
at android.support.v4.view.ViewPager.onMeasure(Unknown Source)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17479)
at net.simonvt.menudrawer.OverlayDrawer.onMeasure(Unknown Source)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:412)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2532)
at android.view.View.measure(View.java:17479)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2262)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1391)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6585)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: Invalid double: "1271.jpg"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:
我的proguard文件:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,*Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.app.Fragment
-keepclasseswithmembernames class * {
native <methods>;
}
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**
-dontwarn com.google.android.gms.**
-dontwarn okio.**
-dontwarn org.xmlpull.v1.**
-dontwarn com.commonsware.cwac.merge.**
-keep class org.xmlpull.** { *; }
-dontwarn org.xmlpull.v1.**
## Gson
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
## Joda time
-dontwarn org.joda.convert.**
## Guava
-keep,allowoptimization class com.google.inject.** { *; }
-keep,allowoptimization class javax.inject.** { *; }
-keep,allowoptimization class javax.annotation.** { *; }
-keep,allowoptimization class com.google.inject.Binder
## CouchBase-Lite
-keepattributes *Annotation*,EnclosingMethod
-keep public enum * { public static **[] values(); public static ** valueOf(java.lang.String); }
-keepnames class com.codehaus.jackson.** { *; }
-keep class org.ektorp.** { *; }
-keep class com.couchbase.cblite.router.CBLRouter { *; }
-keep class com.couchbase.touchdb.TDCollateJSON { *; }
-keepclasseswithmembers class * { native <methods>; }
## Picasso
-dontwarn com.squareup.okhttp.**
## Zxing
-keep class com.google.zxing.client.android.camera.open.**
-keep class com.google.zxing.client.android.common.executor.**
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
-keepclassmembers,allowoptimization class com.google.common.* {
void finalizeReferent();
void startFinalizer(java.lang.Class,java.lang.Object);
}
#eventbus
-keepclassmembers class ** {
public void onEvent*(**);
}
-dontnote android.**
-dontnote java.**
-dontnote javax.**
-dontnote junit.**
-dontnote org.**
-dontnote dalvik.**
-dontnote com.android.internal.**
# Stop warnings about missing unused classes
-dontwarn com.google.common.**
-dontnote com.google.common.**
答案 0 :(得分:0)
我将此配置用于我的GSON程序,尝试并让我知道
## GSON 2.2.4 specific rules ##
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
-keepattributes EnclosingMethod
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }