Parcelable问题模糊处理时使用ProGuard [英] Parcelable Issues When Obfuscating With Proguard
问题描述
我的应用程序的工作原理之前混淆罚款,但是当我使我的ProGuard收到以下错误:
2013年5月2日13:43:58.772è30138 / AndroidRuntime:致命的异常:主要java.lang.NumberFormatException:无效长:0.20
在java.lang.Long.invalidLong(Long.java:125)
在java.lang.Long.parse(Long.java:362)
在java.lang.Long.parseLong(Long.java:353)
在java.lang.Long.parseLong(Long.java:319)
在com.sourcetone.data.model.Station.long的getId()(的SourceFile:195)
在com.sourcetone.STStationListFragment.void deleteStation(com.sourcetone.data.model.Station)(的SourceFile:298)
在com.sourcetone.STStationListFragment.void访问$ 4(com.sourcetone.STStationListFragment,com.sourcetone.data.model.Station)(的SourceFile:293)
在com.sourcetone.STStationListFragment $ ArrayListAdapter $ 1.void的onClick(android.view.View)(的SourceFile:274)
在android.view.View.performClick(View.java:3528)
在android.view.View $ PerformClick.run(View.java:14217)
在android.os.Handler.handleCallback(Handler.java:605)
在android.os.Handler.dispatchMessage(Handler.java:92)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4482)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:794)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
在dalvik.system.NativeStart.main(本机方法)2013年5月2日13:43:58.803W¯¯472 / ActivityManager:强制完成活动com.sourcetone / .STMainActivity
我ProGuard的配置有以下几点:
-keep类*实现android.os.Parcelable {
公共静态最终android.os.Parcelable $造物主*;
}
所以Parcelable应保持正确的?它的投掷无效的龙其实是我的要求,所以它读错号的另一部分。我必须保持我的Htt presponse类呢?还能是什么呢?
-keep类*实现android.os.Parcelable {
公共静态最终android.os.Parcelable $造物主*;
}
不使你的类的所有内容完整,它只是不断类名和CREATOR方法。
尝试在Parcelable类保持领域也添加类似:
-keepclassmembers类*实现android.os.Parcelable {
公众和LT;领域取代;
}
My app works fine before obfuscation but when I enable proguard I get the following error:
2013-05-02 13:43:58.772 E 30138/AndroidRuntime: FATAL EXCEPTION: main java.lang.NumberFormatException: Invalid long: "0.20"
at java.lang.Long.invalidLong(Long.java:125)
at java.lang.Long.parse(Long.java:362)
at java.lang.Long.parseLong(Long.java:353)
at java.lang.Long.parseLong(Long.java:319)
at com.sourcetone.data.model.Station.long getId()(SourceFile:195)
at com.sourcetone.STStationListFragment.void deleteStation(com.sourcetone.data.model.Station)(SourceFile:298)
at com.sourcetone.STStationListFragment.void access$4(com.sourcetone.STStationListFragment,com.sourcetone.data.model.Station)(SourceFile:293)
at com.sourcetone.STStationListFragment$ArrayListAdapter$1.void onClick(android.view.View)(SourceFile:274)
at android.view.View.performClick(View.java:3528)
at android.view.View$PerformClick.run(View.java:14217)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4482)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
2013-05-02 13:43:58.803 W 472/ActivityManager: Force finishing activity com.sourcetone/.STMainActivity
My proguard config has the following:
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
So Parcelable should be keep right? The Invalid Long that it's throwing is actually another part of my request so it's reading the wrong number. Do I have to keep my HttpResponse class as well? What else could it be?
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Doesn't keep all the content of your class intact, it just keeps the classname and the CREATOR method.
Try to keep the fields too in your Parcelable class, add something like :
-keepclassmembers class * implements android.os.Parcelable {
public <fields>;
}
这篇关于Parcelable问题模糊处理时使用ProGuard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!