Genson与Android-Proguard配置 [英] Genson with Android - Proguard config

查看:147
本文介绍了Genson与Android-Proguard配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android Project中的proguard配置有问题. 我正在使用Genson解析传入的JSON数据. 它速度很快,不需要额外的配置或反序列化程序,因为在服务器端也有Genson.

I have a problem with proguard config in Android Project. I'm using Genson to parse incoming JSON data. It is fast and there is no need for extra configuration or deserializers, because on the Server-side there is also Genson.

一切在调试模式下都可以正常工作,但是在发布时,使用proguard不能正常工作.

Everything works fine in debug mode, but in release, with proguard it doesn't.

不幸的是,我在运行时遇到了一些错误:

Unfortunately I have some error during runtime:

FATAL EXCEPTION: main
Process: com.es.mobile.meedy, PID: 16650
java.lang.UnsupportedOperationException: Couldn't find parameter at 0 from type interface com.owlike.genson.Converter , you should first locate the parameterized type, expand it and then use typeOf.
    at com.owlike.genson.reflect.TypeUtil.typeOf(Unknown Source)
    at com.owlike.genson.GensonBuilder.withConverters(Unknown Source)
    at com.mypackage.f.k.a(Unknown Source)
    at com.a.a.b.n.a(Unknown Source)
    at com.a.a.i.run(Unknown Source)
    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:5086)
    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:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)

即使datamodel在keep类中,它也会发生.我用keep类,类成员等尝试了所有配置.我还能做什么?

It happens even if datamodel is in keep class. I tried all configrations with keep class, classmembers, etc. What else can i do?

编辑

我还知道什么:

  • 我尝试了将班级与项目中的所有班级联系起来.
  • 我和genson一起上课(-keep class com.owlike.genson.** {*;})
  • Instanceof与我的班级表明它是com.owlike.genson.Converter的实例

推荐答案

该问题的解决方案是添加-keepattributes签名

The solution to the problem was to add -keepattributes Signature

如果正在使用注释,则也应启用此选项-keepattributes * Annotation *

If annotations are being used then this option should be enabled too -keepattributes *Annotation*

还必须提供由Genson服务的应用程序类: -保持类com.mypackage.model.** {*; }

Also the application class being ser/de by Genson must also be provided: -keep class com.mypackage.model.** { *; }

这篇关于Genson与Android-Proguard配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆